Skip to content

Commit

Permalink
Render the intervention banner on any page tagged to "browse/business"
Browse files Browse the repository at this point in the history
At this time, we are only using a single survey URL, but this might change
in the coming weeks so that different topic pages require links to different
surveys.
  • Loading branch information
hannako committed Mar 14, 2022
1 parent 899dd9f commit c7d5cd0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
9 changes: 7 additions & 2 deletions app/presenters/content_item/recruitment_banner.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
module ContentItem
module RecruitmentBanner
SURVEY_URLS = { "/browse/tax" => "https://GDSUserResearch.optimalworkshop.com/treejack/724268fr-1" }.freeze
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? }
key = SURVEY_URLS.keys.find { |k| content_tagged_to(k).present? }
SURVEY_URLS[key]
end

Expand All @@ -15,6 +19,7 @@ def mainstream_browse_pages

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
Expand Down
28 changes: 27 additions & 1 deletion test/integration/recruitment_banner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,34 @@ class RecruitmentBannerTest < ActionDispatch::IntegrationTest
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 for pages not tagged to Money and Tax" do
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"]

Expand Down

0 comments on commit c7d5cd0

Please sign in to comment.