Skip to content

Commit 43f118b

Browse files
committed
Add UR recruitment banner to pages tagged to Working browse
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.
1 parent 6f839f5 commit 43f118b

File tree

6 files changed

+79
-1
lines changed

6 files changed

+79
-1
lines changed

app/assets/stylesheets/application.scss

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ $govuk-new-link-styles: true;
2222
@import "govuk_publishing_components/components/govspeak-html-publication";
2323
@import "govuk_publishing_components/components/image-card";
2424
@import "govuk_publishing_components/components/inset-text";
25+
@import "govuk_publishing_components/components/intervention";
2526
@import "govuk_publishing_components/components/inverse-header";
2627
@import "govuk_publishing_components/components/lead-paragraph";
2728
@import "govuk_publishing_components/components/metadata";

app/assets/stylesheets/components/_banner.scss

+4
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@
3434
max-width: 30em;
3535
padding-top: govuk-spacing(2);
3636
}
37+
38+
.gem-c-intervention {
39+
margin-top: govuk-spacing(4);
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module ContentItem
2+
module RecruitmentBanner
3+
SURVEY_URL_ONE = "https://GDSUserResearch.optimalworkshop.com/treejack/61ec38b742396bc23d00104953ffb17d".freeze
4+
SURVEY_URLS = {
5+
"/browse/working" => SURVEY_URL_ONE,
6+
}.freeze
7+
8+
def recruitment_survey_url
9+
key = SURVEY_URLS.keys.find { |k| content_tagged_to(k).present? }
10+
SURVEY_URLS[key]
11+
end
12+
13+
private
14+
15+
def mainstream_browse_pages
16+
content_item["links"]["mainstream_browse_pages"] if content_item["links"]
17+
end
18+
19+
def content_tagged_to(browse_base_path)
20+
return [] unless mainstream_browse_pages
21+
22+
mainstream_browse_pages.find do |mainstream_browse_page|
23+
mainstream_browse_page["base_path"].starts_with? browse_base_path
24+
end
25+
end
26+
end
27+
end

app/presenters/content_item_presenter.rb

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ class ContentItemPresenter
22
include ContentItem::Withdrawable
33
include ContentItem::BrexitTaxons
44
include ContentItem::SinglePageNotificationButton
5+
include ContentItem::RecruitmentBanner
56
attr_reader :content_item,
67
:requested_path,
78
:view_context,

app/views/layouts/application.html.erb

+8-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@
3131
</head>
3232
<body>
3333
<div id="wrapper" class="<%= wrapper_class %>">
34-
<% if @content_item.show_phase_banner? %>
34+
<% if @content_item.recruitment_survey_url %>
35+
<%= render "govuk_publishing_components/components/intervention", {
36+
suggestion_text: "Help improve GOV.UK",
37+
suggestion_link_text: "Take part in user research",
38+
suggestion_link_url: @content_item.recruitment_survey_url,
39+
new_tab: true,
40+
} %>
41+
<% elsif @content_item.show_phase_banner? %>
3542
<%= render 'govuk_publishing_components/components/phase_banner', phase: @content_item.phase %>
3643
<% end %>
3744

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
require "test_helper"
2+
3+
class RecruitmentBannerTest < ActionDispatch::IntegrationTest
4+
test "Recruitment Banner is displayed for any page tagged to Working, jobs and pensions" do
5+
@working_browse_page = {
6+
"content_id" => "123",
7+
"title" => "Self Assessment",
8+
"base_path" => "/browse/working/self-assessment",
9+
}
10+
11+
guide = GovukSchemas::Example.find("guide", example_name: "guide")
12+
guide["links"]["mainstream_browse_pages"] = []
13+
guide["links"]["mainstream_browse_pages"] << @working_browse_page
14+
15+
stub_content_store_has_item(guide["base_path"], guide.to_json)
16+
visit guide["base_path"]
17+
18+
assert page.has_css?(".gem-c-intervention")
19+
assert page.has_link?("Take part in user research (opens in a new tab)", href: "https://GDSUserResearch.optimalworkshop.com/treejack/61ec38b742396bc23d00104953ffb17d")
20+
end
21+
22+
test "Recruitment Banner is not displayed unless page is tagged to a topic of interest" do
23+
@not_of_interest = {
24+
"content_id" => "123",
25+
"title" => "I am not interesting",
26+
"base_path" => "/browse/boring",
27+
}
28+
29+
guide = GovukSchemas::Example.find("guide", example_name: "guide")
30+
guide["links"]["mainstream_browse_pages"] = []
31+
guide["links"]["mainstream_browse_pages"] << @not_of_interest
32+
stub_content_store_has_item(guide["base_path"], guide.to_json)
33+
visit_with_cachebust guide["base_path"]
34+
35+
assert_not page.has_css?(".gem-c-intervention")
36+
assert_not page.has_link?("Take part in user research", href: "https://GDSUserResearch.optimalworkshop.com/treejack/61ec38b742396bc23d00104953ffb17d")
37+
end
38+
end

0 commit comments

Comments
 (0)