diff --git a/app/controllers/content_items_controller.rb b/app/controllers/content_items_controller.rb
index e8f8009cc..3f6b17fc4 100644
--- a/app/controllers/content_items_controller.rb
+++ b/app/controllers/content_items_controller.rb
@@ -4,6 +4,7 @@ class ContentItemsController < ApplicationController
include GovukPersonalisation::ControllerConcern
include Slimmer::Headers
include Slimmer::Template
+ include RecruitmentBannerHelper
rescue_from GdsApi::HTTPForbidden, with: :error_403
rescue_from GdsApi::HTTPNotFound, with: :error_notfound
diff --git a/app/helpers/recruitment_banner_helper.rb b/app/helpers/recruitment_banner_helper.rb
new file mode 100644
index 000000000..c7eb0f3e9
--- /dev/null
+++ b/app/helpers/recruitment_banner_helper.rb
@@ -0,0 +1,27 @@
+module RecruitmentBannerHelper
+ def recruitment_banner
+ return false if recruitment_banners.nil?
+
+ current_path = request.path
+
+ recruitment_banners.find do |banner|
+ next unless valid?(banner)
+
+ banner["page_paths"]&.include?(current_path)
+ end
+ end
+
+ def recruitment_banners
+ recruitment_banners_urls_file_path = Rails.root.join("lib/data/recruitment_banners.yml")
+ recruitment_banners_data = YAML.load_file(recruitment_banners_urls_file_path)
+ recruitment_banners_data["banners"]
+ end
+
+ def valid?(banner)
+ required_fields.select { |field| banner[field].present? } == required_fields
+ end
+
+ def required_fields
+ %w[survey_url suggestion_text suggestion_link_text page_paths]
+ end
+end
diff --git a/app/presenters/content_item/recruitment_banner.rb b/app/presenters/content_item/recruitment_banner.rb
deleted file mode 100644
index 952864d9e..000000000
--- a/app/presenters/content_item/recruitment_banner.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-module ContentItem
- module RecruitmentBanner
- SURVEY_URL = "https://signup.take-part-in-research.service.gov.uk/".freeze
- SURVEY_URL_MAPPINGS = {
- "/guidance/check-employment-status-for-tax" => "#{SURVEY_URL}?utm_campaign=List_CEST_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=577",
- "/guidance/corporation-tax-trading-and-non-trading" => "#{SURVEY_URL}?utm_campaign=List_Corp_Tax_trading_and_non_trading_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=578",
- "/guidance/how-to-fill-in-and-submit-your-vat-return-vat-notice-70012" => "#{SURVEY_URL}?utm_campaign=List_Fill_and_submit_VAT_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=579",
- "/guidance/sign-in-to-your-hmrc-business-tax-account" => "#{SURVEY_URL}?utm_campaign=List_Sign_in_BTA_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=580",
- "/guidance/rates-of-vat-on-different-goods-and-services" => "#{SURVEY_URL}?utm_campaign=List_VAT_on_goods_and_services_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=581",
- "/guidance/claim-a-refund-of-construction-industry-scheme-deductions-if-youre-a-limited-company" => "#{SURVEY_URL}?utm_campaign=List_CIS_refund_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=582",
- "/guidance/understanding-off-payroll-working-ir35" => "#{SURVEY_URL}?utm_campaign=List_IR35_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=583",
- "/guidance/tax-reliefs-and-allowances-for-businesses-employers-and-the-self-employed" => "#{SURVEY_URL}?utm_campaign=List_Tax_reliefs_and_allowances_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=584",
- "/guidance/corporation-tax-selling-or-closing-your-company" => "#{SURVEY_URL}?utm_campaign=List_Corp_Tax_selling_or_closing_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=585",
- "/guidance/check-when-you-can-expect-a-reply-from-hmrc" => "#{SURVEY_URL}?utm_campaign=List_Expect_a_reply_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=586",
- }.freeze
-
- def recruitment_survey_url
- key = content_item["base_path"]
- SURVEY_URL_MAPPINGS[key]
- end
- end
-end
diff --git a/app/presenters/content_item_presenter.rb b/app/presenters/content_item_presenter.rb
index ca3151668..850db6aa7 100644
--- a/app/presenters/content_item_presenter.rb
+++ b/app/presenters/content_item_presenter.rb
@@ -1,6 +1,5 @@
class ContentItemPresenter
include ContentItem::Withdrawable
- include ContentItem::RecruitmentBanner
attr_reader :content_item,
:requested_path,
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index dfe85d690..575388131 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -23,16 +23,7 @@
<% end %>
<% end %>
- <% if @content_item.recruitment_survey_url %>
-
- <%= render "govuk_publishing_components/components/intervention", {
- suggestion_text: "Help improve GOV.UK",
- suggestion_link_text: "Sign up to take part in user research (opens in a new tab)",
- suggestion_link_url: @content_item.recruitment_survey_url,
- new_tab: true,
- } %>
-
- <% end %>
+ <%= render partial: 'shared/intervention_banner' %>
<%= yield :header %>
diff --git a/app/views/shared/_intervention_banner.html.erb b/app/views/shared/_intervention_banner.html.erb
new file mode 100644
index 000000000..874c5f513
--- /dev/null
+++ b/app/views/shared/_intervention_banner.html.erb
@@ -0,0 +1,10 @@
+<% if recruitment_banner.present? %>
+
+ <%= render "govuk_publishing_components/components/intervention", {
+ new_tab: true,
+ suggestion_text: recruitment_banner["suggestion_text"],
+ suggestion_link_text: recruitment_banner["suggestion_link_text"],
+ suggestion_link_url: recruitment_banner["survey_url"],
+ } %>
+
+<% end %>
diff --git a/lib/data/recruitment_banners.yml b/lib/data/recruitment_banners.yml
new file mode 100644
index 000000000..69ae0e850
--- /dev/null
+++ b/lib/data/recruitment_banners.yml
@@ -0,0 +1,80 @@
+# Example usage of adding a banner to the banners list:
+
+ # - name: Banner 1
+ # suggestion_text: "Help improve GOV.UK"
+ # suggestion_link_text: "Sign up to take part in user research (opens in a new tab)"
+ # survey_url: https://google.com
+ # page_paths:
+ # - /
+ # - /foreign-travel-advice
+
+banners:
+ - name: HMRC Team Banner
+ suggestion_text: "Help improve GOV.UK"
+ suggestion_link_text: "Sign up to take part in user research (opens in a new tab)"
+ survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_CEST_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=577
+ page_paths:
+ - /guidance/check-employment-status-for-tax
+
+ - name: HMRC Team Banner
+ suggestion_text: "Help improve GOV.UK"
+ suggestion_link_text: "Sign up to take part in user research (opens in a new tab)"
+ survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_Corp_Tax_trading_and_non_trading_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=578
+ page_paths:
+ - /guidance/corporation-tax-trading-and-non-trading
+
+ - name: HMRC Team Banner
+ suggestion_text: "Help improve GOV.UK"
+ suggestion_link_text: "Sign up to take part in user research (opens in a new tab)"
+ survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_Fill_and_submit_VAT_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=579
+ page_paths:
+ - /guidance/how-to-fill-in-and-submit-your-vat-return-vat-notice-70012
+
+ - name: HMRC Team Banner
+ suggestion_text: "Help improve GOV.UK"
+ suggestion_link_text: "Sign up to take part in user research (opens in a new tab)"
+ survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_Sign_in_BTA_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=580
+ page_paths:
+ - /guidance/sign-in-to-your-hmrc-business-tax-account
+
+ - name: HMRC Team Banner
+ suggestion_text: "Help improve GOV.UK"
+ suggestion_link_text: "Sign up to take part in user research (opens in a new tab)"
+ survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_VAT_on_goods_and_services_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=581
+ page_paths:
+ - /guidance/rates-of-vat-on-different-goods-and-services
+
+ - name: HMRC Team Banner
+ suggestion_text: "Help improve GOV.UK"
+ suggestion_link_text: "Sign up to take part in user research (opens in a new tab)"
+ survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_CIS_refund_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=582
+ page_paths:
+ - /guidance/claim-a-refund-of-construction-industry-scheme-deductions-if-youre-a-limited-company
+
+ - name: HMRC Team Banner
+ suggestion_text: "Help improve GOV.UK"
+ suggestion_link_text: "Sign up to take part in user research (opens in a new tab)"
+ survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_IR35_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=583
+ page_paths:
+ - /guidance/understanding-off-payroll-working-ir35
+
+ - name: HMRC Team Banner
+ suggestion_text: "Help improve GOV.UK"
+ suggestion_link_text: "Sign up to take part in user research (opens in a new tab)"
+ survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_Tax_reliefs_and_allowances_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=584
+ page_paths:
+ - /guidance/tax-reliefs-and-allowances-for-businesses-employers-and-the-self-employed
+
+ - name: HMRC Team Banner
+ suggestion_text: "Help improve GOV.UK"
+ suggestion_link_text: "Sign up to take part in user research (opens in a new tab)"
+ survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_Corp_Tax_selling_or_closing_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=585
+ page_paths:
+ - /guidance/corporation-tax-selling-or-closing-your-company
+
+ - name: HMRC Team Banner
+ suggestion_text: "Help improve GOV.UK"
+ suggestion_link_text: "Sign up to take part in user research (opens in a new tab)"
+ survey_url: https://signup.take-part-in-research.service.gov.uk/?utm_campaign=List_Expect_a_reply_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=586
+ page_paths:
+ - /guidance/check-when-you-can-expect-a-reply-from-hmrc
diff --git a/test/fixtures/recruitment_banners.yml b/test/fixtures/recruitment_banners.yml
new file mode 100644
index 000000000..d0a1cf5cd
--- /dev/null
+++ b/test/fixtures/recruitment_banners.yml
@@ -0,0 +1,14 @@
+banners:
+ - name: Banner 1
+ suggestion_text: "Help improve GOV.UK"
+ suggestion_link_text: "Take part in user research"
+ survey_url: https://google.com
+ page_paths:
+ - /
+
+ - name: Banner 2
+ suggestion_text: "Help improve GOV.UK"
+ suggestion_link_text: "Take part in user research"
+ survey_url: https://google.com
+ page_paths:
+ - /some_path
diff --git a/test/unit/helpers/recruitment_banner_helper_test.rb b/test/unit/helpers/recruitment_banner_helper_test.rb
new file mode 100644
index 000000000..3c261853f
--- /dev/null
+++ b/test/unit/helpers/recruitment_banner_helper_test.rb
@@ -0,0 +1,51 @@
+require "test_helper"
+
+class RecruitmentBannerHelperTest < ActionView::TestCase
+ include RecruitmentBannerHelper
+
+ def setup
+ @recruitment_banners_data = YAML.load_file(Rails.root.join("test/fixtures/recruitment_banners.yml"))
+ end
+
+ def request
+ OpenStruct.new(path: "/")
+ end
+
+ def recruitment_banners
+ @recruitment_banners_data["banners"]
+ end
+
+ test "recruitment_banner returns banners that include the current url" do
+ actual_banners = recruitment_banner
+
+ expected_banners =
+ {
+ "name" => "Banner 1",
+ "suggestion_text" => "Help improve GOV.UK",
+ "suggestion_link_text" => "Take part in user research",
+ "survey_url" => "https://google.com",
+ "page_paths" => ["/"],
+ }
+ assert_equal expected_banners, actual_banners
+ end
+
+ test "recruitment_banners yaml structure is valid" do
+ @recruitment_banners_data = YAML.load_file(Rails.root.join("lib/data/recruitment_banners.yml"))
+
+ if @recruitment_banners_data["banners"].present?
+ recruitment_banners.each do |banner|
+ assert banner.key?("suggestion_text"), "Banner is missing 'suggestion_text' key"
+ assert_not banner["suggestion_text"].blank?, "'suggestion_text' key should not be blank"
+
+ assert banner.key?("suggestion_link_text"), "Banner is missing 'suggestion_link_text' key"
+ assert_not banner["suggestion_link_text"].blank?, "'suggestion_link_text' key should not be blank"
+
+ assert banner.key?("survey_url"), "Banner is missing 'survey_url' key"
+ assert_not banner["survey_url"].blank?, "'survey_url' key should not be blank"
+
+ assert banner.key?("page_paths"), "Banner is missing 'page_paths' key"
+ assert_not banner["page_paths"].blank?, "'page_paths' key should not be blank"
+ end
+ end
+ end
+end