Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'already subscribed' email flash banner #2322

Merged
merged 1 commit into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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