Skip to content

Commit

Permalink
Merge pull request #2943 from alphagov/update-taxonomy-signup-link
Browse files Browse the repository at this point in the history
Update taxonomy topic email signup button
  • Loading branch information
hannako authored Oct 30, 2023
2 parents 72b54ad + 4d2c8a4 commit 44300c5
Showing 5 changed files with 25 additions and 23 deletions.
6 changes: 1 addition & 5 deletions app/views/content_items/document_collection.html.erb
Original file line number Diff line number Diff line change
@@ -22,11 +22,7 @@
</div>

<%= 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 %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
21 changes: 21 additions & 0 deletions app/views/shared/_document_collections_email_signup.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<% if @content_item.taxonomy_topic_email_override_base_path.present? %>
<div
data-module="ga4-link-tracker"
data-ga4-link='{ "event_name": "navigation", "type": "subscribe", "index": { "index_link": 1 }, "index_total": 1, "section": "Top" }'
data-ga4-track-links-only
>
<%= 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
} %>
</div>
<% else %>
<%= render 'shared/single_page_notification_button', content_item: @content_item, skip_account: "true" %>
<% end %>
17 changes: 0 additions & 17 deletions app/views/shared/_taxon_signup_link.html.erb

This file was deleted.

2 changes: 2 additions & 0 deletions test/integration/document_collection_test.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -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"])

0 comments on commit 44300c5

Please sign in to comment.