Skip to content

Commit

Permalink
Set up DWP user research banner
Browse files Browse the repository at this point in the history
  • Loading branch information
beccapearce committed Mar 19, 2024
1 parent f09d815 commit b0cb4a0
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/controllers/browse_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class BrowseController < ApplicationController
slimmer_template "gem_layout_full_width"
include RecruitmentBannerHelper

def index
page = MainstreamBrowsePage.find("/browse")
Expand Down
1 change: 1 addition & 0 deletions app/controllers/organisations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class OrganisationsController < ApplicationController
skip_before_action :set_expiry
include RecruitmentBannerHelper
before_action do
set_expiry content_item.max_age, public_cache: content_item.public_cache
end
Expand Down
3 changes: 2 additions & 1 deletion app/views/browse/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<% add_view_stylesheet("browse") %>
<% content_for :title, page.title %>
<%= render 'shared/tag_meta', tag: page %>
Expand All @@ -20,6 +19,8 @@
} %>
<% end %>
<%= render partial: 'shared/intervention_banner' %>
<%= render "shared/browse_header", { margin_bottom: page.slug == "benefits" ? 7 : 9 } do %>
<h1 class="browse__heading govuk-heading-xl">
<%= page.title %>
Expand Down
1 change: 1 addition & 0 deletions app/views/organisations/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<%= render partial: 'meta', locals: { organisation: @organisation } %>
<%= render partial: 'breadcrumb' %>
<%= render partial: 'shared/intervention_banner' %>
<%= render partial: 'header' %>
<%= render 'govuk_publishing_components/components/machine_readable_metadata',
schema: :organisation,
Expand Down
7 changes: 7 additions & 0 deletions lib/data/recruitment_banners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
# - /foreign-travel-advice

banners:
- name: DWP user research banner
suggestion_text: Help improve GOV.UK
suggestion_link_text: Take part in user research (opens in a new tab)
survey_url: https://forms.office.com/e/CkfCRwdLQj
page_paths:
- /government/organisations/department-for-work-pensions
- /browse/benefits
43 changes: 43 additions & 0 deletions spec/features/recruitment_banner_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require "integration_spec_helper"

RSpec.feature "Research panel banner" do
include SearchApiHelpers
include OrganisationHelpers
include RecruitmentBannerHelper

scenario "browse pages where we want to display Brand User Research banner" do
base_path = "/browse/benefits"
schema = GovukSchemas::Example.find("mainstream_browse_page", example_name: "level_2_page")
schema["base_path"] = base_path
stub_content_store_has_item(schema["base_path"], schema)
search_api_has_documents_for_browse_page(schema["content_id"], [base_path], page_size: SearchApiSearch::PAGE_SIZE_TO_GET_EVERYTHING)

visit schema["base_path"]

expect(page.status_code).to eq(200)
expect(page).to have_selector(".gem-c-intervention")
end

scenario "organisation pages where we want to display Brand User Research banner" do
base_path = "/government/organisations/department-for-work-pensions"
schema = GovukSchemas::Example.find("organisation", example_name: "tribunal")
schema["base_path"] = base_path
stub_content_and_search(schema)

visit schema["base_path"]

expect(page.status_code).to eq(200)
expect(page).to have_selector(".gem-c-intervention")
end

scenario "pages where we don't want to display Brand User Research banner" do
schema = GovukSchemas::Example.find("mainstream_browse_page", example_name: "level_2_page")
stub_content_store_has_item(schema["base_path"], schema)
search_api_has_documents_for_browse_page(schema["content_id"], [schema["base_path"]], page_size: SearchApiSearch::PAGE_SIZE_TO_GET_EVERYTHING)

visit schema["base_path"]

expect(page.status_code).to eq(200)
expect(page).to_not have_selector(".gem-c-intervention")
end
end

0 comments on commit b0cb4a0

Please sign in to comment.