From b4c0f7c8ae65fdcffb14381300ea36028c6c5f92 Mon Sep 17 00:00:00 2001 From: Ryan Brown Date: Thu, 16 Jan 2025 16:08:47 +0000 Subject: [PATCH] Make feedback banner use the configuration in the locale file The feedback banner has a locale configuration value, but we had stopped using it at some point in favour of a variable in the phase banner template file. This came as a bit of a surprise, resulting in the feedback banner being live unexpectedly. --- app/views/shared/_phase_banner.html.erb | 5 ++- test/integration/maintenance_banner_test.rb | 15 --------- test/integration/phase_banner_test.rb | 37 +++++++++++++++++++++ test/integration/whats_new_test.rb | 11 ------ 4 files changed, 39 insertions(+), 29 deletions(-) delete mode 100644 test/integration/maintenance_banner_test.rb create mode 100644 test/integration/phase_banner_test.rb diff --git a/app/views/shared/_phase_banner.html.erb b/app/views/shared/_phase_banner.html.erb index f6663c32297..6ee043cb6f4 100644 --- a/app/views/shared/_phase_banner.html.erb +++ b/app/views/shared/_phase_banner.html.erb @@ -1,5 +1,3 @@ -<% show_feedback_banner ||= true %> - <% if t('admin.whats_new.show_banner') %> <%= render "govuk_publishing_components/components/phase_banner", { id: "whats_new_banner", @@ -15,7 +13,8 @@ ) }.", attributes: %w(class href)), } %> -<% elsif show_feedback_banner %> +<% end %> +<% if t('admin.feedback.show_banner') %> <%= render "govuk_publishing_components/components/phase_banner", { id: "feedback_banner", phase: "Feedback", diff --git a/test/integration/maintenance_banner_test.rb b/test/integration/maintenance_banner_test.rb deleted file mode 100644 index f75e3ec6d0c..00000000000 --- a/test/integration/maintenance_banner_test.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "test_helper" - -class MaintenanceBannerTest < ActionDispatch::IntegrationTest - test "uses the configuration value in the maintenance_banner.yml locale file to determine whether to render the banner" do - login_as create(:gds_editor) - get admin_root_path - - if I18n.t("admin.maintenance_banner.show_banner") - assert_select "#maintenance_banner .govuk-phase-banner__content__tag", text: "Maintenance" - assert_select "#maintenance_banner .govuk-phase-banner__text", text: I18n.t("admin.maintenance_banner.message") - else - assert_select "#maintenance_banner", count: 0 - end - end -end diff --git a/test/integration/phase_banner_test.rb b/test/integration/phase_banner_test.rb new file mode 100644 index 00000000000..d3ffa20632a --- /dev/null +++ b/test/integration/phase_banner_test.rb @@ -0,0 +1,37 @@ +require "test_helper" + +class PhaseBannerTest < ActionDispatch::IntegrationTest + test "uses the show_banner value in the whats_new.yml file to determine whether to render the whats new banner" do + login_as create(:gds_editor) + get admin_root_path + + if I18n.t("admin.whats_new.show_banner") + assert_select "#whats_new_banner .govuk-phase-banner__content__tag", text: "What's new" + else + assert_select "#whats_new_banner.gem-c-phase-banner", count: 0 + end + end + + test "uses the show_banner value in the whats_new.yml file to determine whether to render the feedback banner" do + login_as create(:gds_editor) + get admin_root_path + + if I18n.t("admin.feedback.show_banner") + assert_select "#feedback_banner .govuk-phase-banner__content__tag", text: "Feedback" + else + assert_select "#feedback_banner", count: 0 + end + end + + test "uses the configuration value in the maintenance_banner.yml locale file to determine whether to render the banner" do + login_as create(:gds_editor) + get admin_root_path + + if I18n.t("admin.maintenance_banner.show_banner") + assert_select "#maintenance_banner .govuk-phase-banner__content__tag", text: "Maintenance" + assert_select "#maintenance_banner .govuk-phase-banner__text", text: I18n.t("admin.maintenance_banner.message") + else + assert_select "#maintenance_banner", count: 0 + end + end +end diff --git a/test/integration/whats_new_test.rb b/test/integration/whats_new_test.rb index c3b2ade633c..a094ebaeb18 100644 --- a/test/integration/whats_new_test.rb +++ b/test/integration/whats_new_test.rb @@ -19,15 +19,4 @@ class WhatsNewTest < ActionDispatch::IntegrationTest end end end - - test "uses the show_banner value in the whats_new.yml file to determine whether to render the banner" do - login_as create(:gds_editor) - get admin_whats_new_path - - if I18n.t("admin.whats_new.show_banner") || I18n.t("admin.feedback.show_banner") - assert_select "#whats_new_banner.gem-c-phase-banner", count: 1 - else - assert_select "#whats_new_banner.gem-c-phase-banner", count: 0 - end - end end