Skip to content

Commit

Permalink
Add 'already subscribed' email flash banner
Browse files Browse the repository at this point in the history
Handle the new flash message variation added in alphagov/email-alert-frontend#1223
which should be shown when a user clicks the button to subscribe to
email alerts about a page, but is already subscribed.
  • Loading branch information
asmith-nhsx committed Dec 22, 2021
1 parent 57ae616 commit 7a8ca46
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/views/shared/_email_subscribe_unsubscribe_flash.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,14 @@
} %>
</div>
</div>
<% elsif @account_flash.include?("email-subscribe-already-subscribed") %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds govuk-!-margin-top-3">
<%= render "govuk_publishing_components/components/success_alert", {
message: sanitize(t("email.already_subscribed_title")),
description: sanitize(t("email.description_html")),
margin_bottom: 0,
} %>
</div>
</div>
<% end %>
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ en:
description_html: <p class="govuk-body">Go to your GOV.UK account to <a class="govuk-link govuk-notification-banner__link" href="/email/manage">see and manage all your GOV.UK email subscriptions</a>.</p>
subscribe_title: You’ve subscribed to emails about this page
unsubscribe_title: You’ve unsubscribed from emails about this page
already_subscribed_title: You’re already getting emails about this page
fatality_notice:
alt_text: Ministry of Defence crest
field_of_operation: Field of operation
Expand Down
8 changes: 8 additions & 0 deletions test/controllers/content_items_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,14 @@ class ContentItemsControllerTest < ActionController::TestCase
assert response.body.include?("unsubscribed from emails about this page")
end

test "displays the already subscribed success banner when the 'email-subscribe-already-subscribed' flash is present" do
content_item = content_store_has_schema_example("publication", "publication")

request.headers["GOVUK-Account-Session"] = GovukPersonalisation::Flash.encode_session("session-id", %w[email-subscribe-already-subscribed])
get :show, params: { path: path_for(content_item) }
assert response.body.include?("already getting emails about this page")
end

def path_for(content_item, locale = nil)
base_path = content_item["base_path"].sub(/^\//, "")
base_path.gsub!(/\.#{locale}$/, "") if locale
Expand Down

0 comments on commit 7a8ca46

Please sign in to comment.