Skip to content

Commit 930513d

Browse files
committed
Enable taxonomy email signup for document collection
Allow users to sign up to a mapped taxonomy topic email subscription from some document collection pages if taxonomy_topic_email_override is present.
1 parent 8f37863 commit 930513d

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

app/presenters/document_collection_presenter.rb

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def group_heading(group)
6363
)
6464
end
6565

66+
def taxonomy_topic_email_override_base_path
67+
content_item.dig("links", "taxonomy_topic_email_override", 0, "base_path")
68+
end
69+
6670
private
6771

6872
def group_documents(group)

app/views/content_items/document_collection.html.erb

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
</div>
2323

2424
<%= render 'shared/publisher_metadata_with_logo' %>
25-
<%= render 'shared/single_page_notification_button', content_item: @content_item, skip_account: "true" %>
25+
<% if @content_item.taxonomy_topic_email_override_base_path.present? %>
26+
<%= render 'shared/taxon_signup_link', base_path: @content_item.taxonomy_topic_email_override_base_path %>
27+
<% else %>
28+
<%= render 'shared/single_page_notification_button', content_item: @content_item %>
29+
<% end %>
2630

2731
<div class="govuk-grid-row">
2832
<div class="govuk-grid-column-two-thirds">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div
2+
data-module="ga4-link-tracker"
3+
data-ga4-link='{ "event_name": "navigation", "type": "subscribe", "index": { "index_link": 1 }, "index_total": 1, "section": "Top" }'
4+
data-ga4-track-links-only
5+
>
6+
<%= render "govuk_publishing_components/components/signup_link", {
7+
link_text: "Get emails about this topic",
8+
link_href: "/email-signup/?link=#{base_path}",
9+
data: {
10+
"module": "gem-track-click",
11+
"track-category": "emailAlertLinkClicked",
12+
"track-action": base_path,
13+
"track-label": ""
14+
},
15+
margin_bottom: 6
16+
} %>
17+
</div>

test/integration/document_collection_test.rb

+6
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,10 @@ class DocumentCollectionTest < ActionDispatch::IntegrationTest
158158
setup_and_visit_content_item("document_collection")
159159
assert page.has_css?(".gem-c-single-page-notification-button")
160160
end
161+
162+
test "renders with the taxonomy subscription button" do
163+
setup_and_visit_content_item_with_taxonomy_topic_email_override("document_collection")
164+
assert page.has_css?(".gem-c-signup-link")
165+
assert_not page.has_css?(".gem-c-single-page-notification-button")
166+
end
161167
end

test/test_helper.rb

+10
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,16 @@ def setup_and_visit_content_item_with_taxons(name, taxons)
195195
end
196196
end
197197

198+
def setup_and_visit_content_item_with_taxonomy_topic_email_override(name)
199+
@content_item = get_content_example(name).tap do |item|
200+
item["links"]["taxonomy_topic_email_override"] = [{
201+
"base_path": "test",
202+
}]
203+
stub_content_store_has_item(item["base_path"], item.to_json)
204+
visit_with_cachebust(item["base_path"])
205+
end
206+
end
207+
198208
def setup_and_visit_notification_exempt_page(name)
199209
@content_item = get_content_example(name).tap do |item|
200210
item["content_id"] = ContentItem::SinglePageNotificationButton::EXEMPTION_LIST[0]

0 commit comments

Comments
 (0)