diff --git a/app/lib/recruitment_helper.rb b/app/lib/recruitment_helper.rb
new file mode 100644
index 000000000..b33714765
--- /dev/null
+++ b/app/lib/recruitment_helper.rb
@@ -0,0 +1,7 @@
+module RecruitmentHelper
+ USER_RESEARCH_PAGES = %w[register-for-self-assessment self-employed-records income-tax-rates].freeze
+
+ def self.show_banner?(slug)
+ USER_RESEARCH_PAGES.include?(slug)
+ end
+end
diff --git a/app/presenters/content_item/recruitment_banner.rb b/app/presenters/content_item/recruitment_banner.rb
new file mode 100644
index 000000000..592821b4f
--- /dev/null
+++ b/app/presenters/content_item/recruitment_banner.rb
@@ -0,0 +1,28 @@
+module ContentItem
+ module RecruitmentBanner
+ SURVEY_URL_ONE = "https://GDSUserResearch.optimalworkshop.com/treejack/724268fr-1".freeze
+ SURVEY_URLS = {
+ "/browse/tax" => SURVEY_URL_ONE,
+ "/browse/business" => SURVEY_URL_ONE,
+ }.freeze
+
+ def recruitment_survey_url
+ key = SURVEY_URLS.keys.find { |k| content_tagged_to(k).present? }
+ SURVEY_URLS[key]
+ end
+
+ private
+
+ def mainstream_browse_pages
+ content_item["links"]["mainstream_browse_pages"] if content_item["links"]
+ end
+
+ def content_tagged_to(browse_base_path)
+ return [] unless mainstream_browse_pages
+
+ mainstream_browse_pages.find do |mainstream_browse_page|
+ mainstream_browse_page["base_path"].starts_with? browse_base_path
+ end
+ end
+ end
+end
diff --git a/app/presenters/content_item_presenter.rb b/app/presenters/content_item_presenter.rb
index f307f3c77..b89336d0a 100644
--- a/app/presenters/content_item_presenter.rb
+++ b/app/presenters/content_item_presenter.rb
@@ -2,7 +2,7 @@ class ContentItemPresenter
include ContentItem::Withdrawable
include ContentItem::BrexitTaxons
include ContentItem::SinglePageNotificationButton
-
+ include ContentItem::RecruitmentBanner
attr_reader :content_item,
:requested_path,
:view_context,
@@ -20,8 +20,6 @@ class ContentItemPresenter
attr_accessor :include_collections_in_other_publisher_metadata
- USER_RESEARCH_PAGES = %w[register-for-self-assessment self-employed-records income-tax-rates].freeze
-
def initialize(content_item, requested_path, view_context)
@content_item = content_item
@requested_path = requested_path
@@ -89,10 +87,6 @@ def show_phase_banner?
phase.in?(%w[alpha beta])
end
- def show_study_banner?
- USER_RESEARCH_PAGES.include?(slug)
- end
-
def render_guide_as_single_page?
# /how-to-vote
content_id == "9315bc67-33e7-42e9-8dea-e022f56dabfa" && voting_is_open?
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index ac96400fe..3be836a81 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -31,11 +31,11 @@
- <% if @content_item.show_study_banner? %>
+ <% if @content_item.recruitment_survey_url %>
<%= render "govuk_publishing_components/components/intervention", {
suggestion_text: "Help improve GOV.UK",
suggestion_link_text: "Take part in user research",
- suggestion_link_url: "https://GDSUserResearch.optimalworkshop.com/treejack/lb5eu75l",
+ suggestion_link_url: @content_item.recruitment_survey_url,
new_tab: true,
} %>
<% elsif @content_item.show_phase_banner? %>
diff --git a/test/integration/guide_test.rb b/test/integration/guide_test.rb
index bc15a4356..8bee5aa18 100644
--- a/test/integration/guide_test.rb
+++ b/test/integration/guide_test.rb
@@ -169,22 +169,6 @@ class GuideTest < ActionDispatch::IntegrationTest
assert_not page.has_css?(".gem-c-single-page-notification-button")
end
- test "does not render intervention banner by default" do
- setup_and_visit_content_item("guide")
-
- assert_not page.has_css?(".gem-c-intervention")
- end
-
- test "renders intervention banner on specific page" do
- user_research_pages = %w[register-for-self-assessment self-employed-records income-tax-rates]
-
- user_research_pages.each do |banner_page|
- setup_and_visit_a_page_with_specific_base_path("guide", "/#{banner_page}")
- end
-
- assert page.has_css?(".gem-c-intervention")
- end
-
def once_voting_has_closed
Timecop.freeze(Time.zone.local(2021, 5, 6, 22, 0, 0))
yield
diff --git a/test/integration/recruitment_banner_test.rb b/test/integration/recruitment_banner_test.rb
new file mode 100644
index 000000000..cd58bca92
--- /dev/null
+++ b/test/integration/recruitment_banner_test.rb
@@ -0,0 +1,56 @@
+require "test_helper"
+
+class RecruitmentBannerTest < ActionDispatch::IntegrationTest
+ test "Recruitment Banner is displayed for any page tagged to Money and Tax" do
+ @money_and_tax_browse_page = {
+ "content_id" => "123",
+ "title" => "Self Assessment",
+ "base_path" => "/browse/tax/self-assessment",
+ }
+
+ guide = GovukSchemas::Example.find("guide", example_name: "guide")
+ guide["links"]["mainstream_browse_pages"] = []
+ guide["links"]["mainstream_browse_pages"] << @money_and_tax_browse_page
+
+ stub_content_store_has_item(guide["base_path"], guide.to_json)
+ visit guide["base_path"]
+
+ assert page.has_css?(".gem-c-intervention")
+ assert page.has_link?("Take part in user research (opens in a new tab)", href: "https://GDSUserResearch.optimalworkshop.com/treejack/724268fr-1")
+ end
+
+ test "Recruitment Banner is displayed for any page tagged to Business and Self-employed" do
+ @business_browse_page = {
+ "content_id" => "123",
+ "title" => "Self Assessment",
+ "base_path" => "/browse/business",
+ }
+
+ guide = GovukSchemas::Example.find("guide", example_name: "guide")
+ guide["links"]["mainstream_browse_pages"] = []
+ guide["links"]["mainstream_browse_pages"] << @business_browse_page
+
+ stub_content_store_has_item(guide["base_path"], guide.to_json)
+ visit guide["base_path"]
+
+ assert page.has_css?(".gem-c-intervention")
+ assert page.has_link?("Take part in user research (opens in a new tab)", href: "https://GDSUserResearch.optimalworkshop.com/treejack/724268fr-1")
+ end
+
+ test "Recruitment Banner is not displayed unless page is tagged to a topic of interest" do
+ @not_of_interest = {
+ "content_id" => "123",
+ "title" => "I am not interesting",
+ "base_path" => "/browse/boring",
+ }
+
+ guide = GovukSchemas::Example.find("guide", example_name: "guide")
+ guide["links"]["mainstream_browse_pages"] = []
+ guide["links"]["mainstream_browse_pages"] << @not_of_interest
+ stub_content_store_has_item(guide["base_path"], guide.to_json)
+ visit_with_cachebust guide["base_path"]
+
+ assert_not page.has_css?(".gem-c-intervention")
+ assert_not page.has_link?("Take part in user research", href: "https://GDSUserResearch.optimalworkshop.com/treejack/724268fr-1")
+ end
+end