Skip to content

Commit

Permalink
Add govuk_web_banners gem
Browse files Browse the repository at this point in the history
- Add JS used by global banners, and banner dependencies
- Add global/emergency banner support in layouts
- Add initializer for emergency banner REDIS support
- Mock redis client in all tests (we're not explicitly
  testing emergency banner support here, since we assume
  that's tested adequately in the gem).
  • Loading branch information
KludgeKML committed Feb 10, 2025
1 parent a8d28b5 commit 1730ba6
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ gem "gds-api-adapters"
gem "govuk_app_config"
gem "govuk_personalisation"
gem "govuk_publishing_components"
gem "govuk_web_banners"
gem "jwt"
gem "plek"
gem "ratelimit"
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ GEM
capybara (>= 3.36)
puma
selenium-webdriver (>= 4.0)
govuk_web_banners (1.0.0)
govuk_app_config
govuk_publishing_components
rails (>= 7)
redis
hashdiff (1.1.2)
http-accept (1.7.0)
http-cookie (1.0.8)
Expand Down Expand Up @@ -651,6 +656,7 @@ DEPENDENCIES
govuk_publishing_components
govuk_schemas
govuk_test
govuk_web_banners
jwt
plek
pry-byebug
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
//= require govuk_publishing_components/components/error-summary
//= require govuk_publishing_components/components/radio
//= require govuk_publishing_components/components/feedback
//= require govuk_publishing_components/components/global-banner
//= require govuk_publishing_components/components/layout-super-navigation-header

//= require govuk_web_banners/dependencies
2 changes: 2 additions & 0 deletions app/views/layouts/account.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<%= render "govuk_publishing_components/components/layout_for_public", {
title: yield(:title),
blue_bar: false,
emergency_banner: render("govuk_web_banners/emergency_banner"),
global_banner: render("govuk_web_banners/global_banner"),
omit_feedback_form: true,
omit_footer_border: true,
omit_global_banner: true,
Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<%= render "govuk_publishing_components/components/layout_for_public", {
title: yield(:title),
show_explore_header: true,
emergency_banner: render("govuk_web_banners/emergency_banner"),
global_banner: render("govuk_web_banners/global_banner"),
} do %>
<%= yield :body %>
<%= javascript_include_tag 'application', type: "module" %>
Expand Down
4 changes: 4 additions & 0 deletions config/initializers/govuk_web_banners.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Rails.application.config.emergency_banner_redis_client = Redis.new(
url: ENV["EMERGENCY_BANNER_REDIS_URL"],
reconnect_attempts: [0, 0.1, 0.25],
)
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
config.before :each do
rate_limiter = instance_double(Ratelimit, add: nil, exceeded?: false)
allow(Ratelimit).to receive(:new).and_return(rate_limiter)
Rails.application.config.emergency_banner_redis_client = instance_double(Redis, hgetall: {})
end
end

0 comments on commit 1730ba6

Please sign in to comment.