Skip to content

Commit

Permalink
Add Brand recruitment banner
Browse files Browse the repository at this point in the history
  • Loading branch information
catalinailie committed Sep 21, 2023
1 parent b5053ba commit 4e92c69
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ $govuk-include-default-font-face: false;
// Components from govuk_publishing_components gem
@import "govuk_publishing_components/govuk_frontend_support";

@import "components/intervention";

// government-frontend mixins
@import "mixins/margins";

Expand Down
3 changes: 3 additions & 0 deletions app/assets/stylesheets/components/_intervention.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.gem-c-intervention {
margin-top: govuk-spacing(4);
}
19 changes: 19 additions & 0 deletions app/presenters/content_item/recruitment_banner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module ContentItem
module RecruitmentBanner
BRAND_SURVEY_URL = "https://surveys.publishing.service.gov.uk/s/5G06FO/".freeze
SURVEY_URL_MAPPINGS = {
"/repaying-your-student-loan" => BRAND_SURVEY_URL,
"/student-finance" => BRAND_SURVEY_URL,
"/jobseekers-allowance" => BRAND_SURVEY_URL,
}.freeze

def recruitment_survey_url
brand_user_research_test_url
end

def brand_user_research_test_url
key = content_item["base_path"]
SURVEY_URL_MAPPINGS[key]
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
@@ -1,5 +1,6 @@
class ContentItemPresenter
include ContentItem::Withdrawable
include ContentItem::RecruitmentBanner

attr_reader :content_item,
:requested_path,
Expand Down
11 changes: 9 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@

<% content_for :body do %>
<div id="wrapper" class="<%= wrapper_class %>">
<% if @content_item.show_phase_banner? || @content_item.service_manual? %>
<% 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? || @content_item.service_manual? %>
<div class="govuk-width-container">
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
Expand All @@ -28,7 +35,7 @@
<%= render 'govuk_publishing_components/components/contextual_breadcrumbs', content_item: @content_item.parsed_content_item, ga4_tracking: true %>
<% end %>
<% end %>

<%= yield :header %>

<main role="main" id="content" class="<%= @content_item.schema_name.dasherize %>" lang="<%= I18n.locale %>">
Expand Down
33 changes: 33 additions & 0 deletions test/integration/recruitment_banner_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require "test_helper"

class RecruitmentBannerTest < ActionDispatch::IntegrationTest
test "Brand user research banner is displayed on pages of interest" do
guide = GovukSchemas::Example.find("guide", example_name: "guide")

pages_of_interest =
[
"/repaying-your-student-loan",
"/student-finance",
"/jobseekers-allowance",
]

pages_of_interest.each do |path|
guide["base_path"] = path
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", href: "https://surveys.publishing.service.gov.uk/s/5G06FO/")
end
end

test "Brand user research banner is not displayed on all pages" do
guide = GovukSchemas::Example.find("guide", example_name: "guide")
guide["base_path"] = "/nothing-to-see-here"
stub_content_store_has_item(guide["base_path"], guide.to_json)
visit guide["base_path"]

assert_not page.has_css?(".gem-c-intervention")
assert_not page.has_link?("Take part in user research", href: "https://surveys.publishing.service.gov.uk/s/5G06FO/")
end
end

0 comments on commit 4e92c69

Please sign in to comment.