Skip to content

Commit

Permalink
Add UR recruitment banner to pages tagged to Working browse
Browse files Browse the repository at this point in the history
The number of responses hasn't been as much as we hoped, so I'd like to put the
banner out more widely. This adds the banner to all pages tagged to 'Working,
jobs and pensions' mainstream browse. Excluding the mainstream browse page itself,
as that's been looked at in the A/B test.
  • Loading branch information
AgaDufrat committed Jul 7, 2022
1 parent 530f4a8 commit aa2b1d7
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ $govuk-new-link-styles: true;
@import "govuk_publishing_components/components/image-card";
@import "govuk_publishing_components/components/input";
@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/label";
@import "govuk_publishing_components/components/lead-paragraph";
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/components/_banner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@
max-width: 30em;
padding-top: govuk-spacing(2);
}

.gem-c-intervention {
margin-top: govuk-spacing(4);
}
27 changes: 27 additions & 0 deletions app/presenters/content_item/recruitment_banner.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions app/presenters/content_item_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
</head>
<body>
<div id="wrapper" class="<%= wrapper_class %>">
<% 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 %>

Expand Down
38 changes: 38 additions & 0 deletions test/integration/recruitment_banner_test.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit aa2b1d7

Please sign in to comment.