diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 81fa46257..f6ca70e0e 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -22,6 +22,7 @@ $govuk-new-link-styles: true; @import "govuk_publishing_components/components/govspeak-html-publication"; @import "govuk_publishing_components/components/image-card"; @import "govuk_publishing_components/components/inset-text"; +@import "govuk_publishing_components/components/intervention"; @import "govuk_publishing_components/components/inverse-header"; @import "govuk_publishing_components/components/lead-paragraph"; @import "govuk_publishing_components/components/metadata"; diff --git a/app/assets/stylesheets/components/_banner.scss b/app/assets/stylesheets/components/_banner.scss index 55c773b78..5349b2e4c 100644 --- a/app/assets/stylesheets/components/_banner.scss +++ b/app/assets/stylesheets/components/_banner.scss @@ -34,3 +34,7 @@ max-width: 30em; padding-top: govuk-spacing(2); } + +.gem-c-intervention { + margin-top: govuk-spacing(4); +} diff --git a/app/presenters/content_item/recruitment_banner.rb b/app/presenters/content_item/recruitment_banner.rb new file mode 100644 index 000000000..b40912fc1 --- /dev/null +++ b/app/presenters/content_item/recruitment_banner.rb @@ -0,0 +1,27 @@ +module ContentItem + module RecruitmentBanner + SURVEY_URL_ONE = "https://GDSUserResearch.optimalworkshop.com/treejack/3z828uy6".freeze + SURVEY_URLS = { + "/browse/working" => 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 fd2a68232..9e21ffce6 100644 --- a/app/presenters/content_item_presenter.rb +++ b/app/presenters/content_item_presenter.rb @@ -2,6 +2,7 @@ class ContentItemPresenter include ContentItem::Withdrawable include ContentItem::BrexitTaxons include ContentItem::SinglePageNotificationButton + include ContentItem::RecruitmentBanner attr_reader :content_item, :requested_path, :view_context, diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6f206e855..4760fc59a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -31,7 +31,14 @@
- <% if @content_item.show_phase_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: @content_item.recruitment_survey_url, + new_tab: true, + } %> + <% elsif @content_item.show_phase_banner? %> <%= render 'govuk_publishing_components/components/phase_banner', phase: @content_item.phase %> <% end %> diff --git a/test/integration/recruitment_banner_test.rb b/test/integration/recruitment_banner_test.rb new file mode 100644 index 000000000..6082f1ce0 --- /dev/null +++ b/test/integration/recruitment_banner_test.rb @@ -0,0 +1,38 @@ +require "test_helper" + +class RecruitmentBannerTest < ActionDispatch::IntegrationTest + test "Recruitment Banner is displayed for any page tagged to Working, jobs and pensions" do + @working_browse_page = { + "content_id" => "123", + "title" => "Self Assessment", + "base_path" => "/browse/working/self-assessment", + } + + guide = GovukSchemas::Example.find("guide", example_name: "guide") + guide["links"]["mainstream_browse_pages"] = [] + guide["links"]["mainstream_browse_pages"] << @working_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/3z828uy6") + 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/3z828uy6") + end +end