From 4d2c8a49244f9b1a2e00095974d23525b94d978d Mon Sep 17 00:00:00 2001 From: Catalina Ilie Date: Tue, 3 Oct 2023 14:36:24 +0100 Subject: [PATCH] Update taxonomy topic email signup button When a document collection is tagged to a level one taxon, we want the email signup link to send the user to the confirmation page instead of the select subtopics page. --- .../document_collection.html.erb | 6 +----- ...document_collections_email_signup.html.erb | 21 +++++++++++++++++++ app/views/shared/_taxon_signup_link.html.erb | 17 --------------- test/integration/document_collection_test.rb | 2 ++ test/test_helper.rb | 2 +- 5 files changed, 25 insertions(+), 23 deletions(-) create mode 100644 app/views/shared/_document_collections_email_signup.html.erb delete mode 100644 app/views/shared/_taxon_signup_link.html.erb diff --git a/app/views/content_items/document_collection.html.erb b/app/views/content_items/document_collection.html.erb index 9abc2cae6..bdd9d040a 100644 --- a/app/views/content_items/document_collection.html.erb +++ b/app/views/content_items/document_collection.html.erb @@ -22,11 +22,7 @@ <%= render 'shared/publisher_metadata_with_logo' %> -<% if @content_item.taxonomy_topic_email_override_base_path.present? %> - <%= render 'shared/taxon_signup_link', base_path: @content_item.taxonomy_topic_email_override_base_path %> -<% else %> - <%= render 'shared/single_page_notification_button', content_item: @content_item, skip_account: "true" %> -<% end %> +<%= render 'shared/document_collections_email_signup', content_item: @content_item %>
diff --git a/app/views/shared/_document_collections_email_signup.html.erb b/app/views/shared/_document_collections_email_signup.html.erb new file mode 100644 index 000000000..98078f1a5 --- /dev/null +++ b/app/views/shared/_document_collections_email_signup.html.erb @@ -0,0 +1,21 @@ +<% if @content_item.taxonomy_topic_email_override_base_path.present? %> +
+ <%= render "govuk_publishing_components/components/signup_link", { + link_text: "Get emails about this topic", + link_href: "/email-signup/confirm?topic=#{@content_item.taxonomy_topic_email_override_base_path}", + data: { + "module": "gem-track-click", + "track-category": "emailAlertLinkClicked", + "track-action": @content_item.taxonomy_topic_email_override_base_path, + "track-label": "" + }, + margin_bottom: 6 + } %> +
+<% else %> + <%= render 'shared/single_page_notification_button', content_item: @content_item, skip_account: "true" %> +<% end %> diff --git a/app/views/shared/_taxon_signup_link.html.erb b/app/views/shared/_taxon_signup_link.html.erb deleted file mode 100644 index d7770b048..000000000 --- a/app/views/shared/_taxon_signup_link.html.erb +++ /dev/null @@ -1,17 +0,0 @@ -
- <%= render "govuk_publishing_components/components/signup_link", { - link_text: "Get emails about this topic", - link_href: "/email-signup/?link=#{base_path}", - data: { - "module": "gem-track-click", - "track-category": "emailAlertLinkClicked", - "track-action": base_path, - "track-label": "" - }, - margin_bottom: 6 - } %> -
diff --git a/test/integration/document_collection_test.rb b/test/integration/document_collection_test.rb index b77e93023..21f93cd7b 100644 --- a/test/integration/document_collection_test.rb +++ b/test/integration/document_collection_test.rb @@ -157,11 +157,13 @@ class DocumentCollectionTest < ActionDispatch::IntegrationTest test "renders with the single page notification button" do setup_and_visit_content_item("document_collection") assert page.has_css?(".gem-c-single-page-notification-button") + assert_not page.has_css?(".gem-c-signup-link") end test "renders with the taxonomy subscription button" do setup_and_visit_content_item_with_taxonomy_topic_email_override("document_collection") assert page.has_css?(".gem-c-signup-link") + assert page.has_link?(href: "/email-signup/confirm?topic=/testpath") assert_not page.has_css?(".gem-c-single-page-notification-button") end end diff --git a/test/test_helper.rb b/test/test_helper.rb index aba36990a..5ba789485 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -198,7 +198,7 @@ def setup_and_visit_content_item_with_taxons(name, taxons) def setup_and_visit_content_item_with_taxonomy_topic_email_override(name) @content_item = get_content_example(name).tap do |item| item["links"]["taxonomy_topic_email_override"] = [{ - "base_path": "test", + "base_path": "/testpath", }] stub_content_store_has_item(item["base_path"], item.to_json) visit_with_cachebust(item["base_path"])