Skip to content

Commit

Permalink
Make feedback banner use the configuration in the locale file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ryanb-gds committed Jan 16, 2025
1 parent b3a9b7f commit b4c0f7c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 29 deletions.
5 changes: 2 additions & 3 deletions app/views/shared/_phase_banner.html.erb
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down
15 changes: 0 additions & 15 deletions test/integration/maintenance_banner_test.rb

This file was deleted.

37 changes: 37 additions & 0 deletions test/integration/phase_banner_test.rb
Original file line number Diff line number Diff line change
@@ -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
11 changes: 0 additions & 11 deletions test/integration/whats_new_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b4c0f7c

Please sign in to comment.