Skip to content

Commit

Permalink
Merge pull request #2378 from alphagov/recruitment-banner
Browse files Browse the repository at this point in the history
Display intervention banner on specific pages for User Research
  • Loading branch information
chao-xian authored Mar 7, 2022
2 parents 1ee0a9c + 7596e60 commit 5a3bdbe
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//= require govuk_publishing_components/components/error-summary
//= require govuk_publishing_components/components/feedback
//= require govuk_publishing_components/components/govspeak
//= require govuk_publishing_components/components/intervention
//= require govuk_publishing_components/components/metadata
//= require govuk_publishing_components/components/print-link
//= require govuk_publishing_components/components/radio
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);
}
6 changes: 6 additions & 0 deletions app/presenters/content_item_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class ContentItemPresenter

attr_accessor :include_collections_in_other_publisher_metadata

USER_RESEARCH_PAGES = %w[register-for-self-assessment self-employed-records income-tax-rates].freeze

def initialize(content_item, requested_path, view_context)
@content_item = content_item
@requested_path = requested_path
Expand Down Expand Up @@ -87,6 +89,10 @@ def show_phase_banner?
phase.in?(%w[alpha beta])
end

def show_study_banner?
USER_RESEARCH_PAGES.include?(slug)
end

def render_guide_as_single_page?
# /how-to-vote
content_id == "9315bc67-33e7-42e9-8dea-e022f56dabfa" && voting_is_open?
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.show_study_banner? %>
<%= render "govuk_publishing_components/components/intervention", {
suggestion_text: "Help improve GOV.UK",
suggestion_link_text: "Take part in user research",
suggestion_link_url: "https://GDSUserResearch.optimalworkshop.com/treejack/lb5eu75l",
new_tab: true,
} %>
<% elsif @content_item.show_phase_banner? %>
<%= render 'govuk_publishing_components/components/phase_banner', phase: @content_item.phase %>
<% end %>

Expand Down
16 changes: 16 additions & 0 deletions test/integration/guide_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,22 @@ class GuideTest < ActionDispatch::IntegrationTest
assert_not page.has_css?(".gem-c-single-page-notification-button")
end

test "does not render intervention banner by default" do
setup_and_visit_content_item("guide")

assert_not page.has_css?(".gem-c-intervention")
end

test "renders intervention banner on specific page" do
user_research_pages = %w[register-for-self-assessment self-employed-records income-tax-rates]

user_research_pages.each do |banner_page|
setup_and_visit_a_page_with_specific_base_path("guide", "/#{banner_page}")
end

assert page.has_css?(".gem-c-intervention")
end

def once_voting_has_closed
Timecop.freeze(Time.zone.local(2021, 5, 6, 22, 0, 0))
yield
Expand Down
9 changes: 9 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ def setup_and_visit_notification_exempt_page(name)
end
end

def setup_and_visit_a_page_with_specific_base_path(name, base_path, content_id = nil)
@content_item = get_content_example(name).tap do |item|
item["content_id"] = content_id if content_id.present?
item["base_path"] = base_path
stub_content_store_has_item(item["base_path"], item.to_json)
visit_with_cachebust(item["base_path"])
end
end

def brexit_citizen_id
ContentItem::BrexitTaxons::BREXIT_CITIZEN_PAGE_CONTENT_ID
end
Expand Down

0 comments on commit 5a3bdbe

Please sign in to comment.