diff --git a/app/views/admin/overview/_notices.html.erb b/app/views/admin/overview/_notices.html.erb new file mode 100644 index 000000000..70e2f785d --- /dev/null +++ b/app/views/admin/overview/_notices.html.erb @@ -0,0 +1,11 @@ + +<% if ForemInstance.deployed_at.to_i.positive? && ForemInstance.deployed_at < 2.weeks.ago %> +
mb-6"> +

+ It has been <%= time_ago_in_words ForemInstance.deployed_at %> since this Forem was deployed. We recommend you re-deploy from the main branch to stay up-to-date. +

+

+ If you stay out of date for too long, it greatly increases the risk that something could go wrong when you try to re-deploy. +

+
+<% end %> diff --git a/app/views/admin/overview/index.html.erb b/app/views/admin/overview/index.html.erb index f025fb52e..f7c178299 100644 --- a/app/views/admin/overview/index.html.erb +++ b/app/views/admin/overview/index.html.erb @@ -3,6 +3,7 @@

Overview

+<%= render "notices" %>
diff --git a/spec/requests/admin/overview_spec.rb b/spec/requests/admin/overview_spec.rb index badd13d72..5a53a9625 100644 --- a/spec/requests/admin/overview_spec.rb +++ b/spec/requests/admin/overview_spec.rb @@ -8,6 +8,31 @@ RSpec.describe "/admin" do allow(FeatureFlag).to receive(:enabled?).and_call_original end + describe "Notices" do + it "does not show warning if deployed at is recent" do + allow(ForemInstance).to receive(:deployed_at).and_return(1.day.ago) + get admin_path + + expect(response.body).not_to include("If you stay out of date for too long") + end + + it "shows warning notice if deployed at is over two weeks ago" do + allow(ForemInstance).to receive(:deployed_at).and_return(3.weeks.ago) + get admin_path + + expect(response.body).to include("If you stay out of date for too long") + expect(response.body).to include("crayons-notice--warning") + end + + it "shows danger notice if deployed at is over four weeks ago" do + allow(ForemInstance).to receive(:deployed_at).and_return(5.weeks.ago) + get admin_path + + expect(response.body).to include("If you stay out of date for too long") + expect(response.body).to include("crayons-notice--danger") + end + end + describe "Last deployed and Latest Commit ID card" do before do ForemInstance.instance_variable_set(:@deployed_at, nil)