From 76181ce556cf2e69c5478718e54e2553c25d9ffc Mon Sep 17 00:00:00 2001 From: Jessica Jones Date: Tue, 10 Dec 2024 13:07:15 +0000 Subject: [PATCH] Remove legacy implementation of UR banner --- app/helpers/recruitment_banner_helper.rb | 27 ---------- app/views/content_items/answer.html.erb | 1 - .../content_items/detailed_guide.html.erb | 1 - .../document_collection.html.erb | 3 +- app/views/content_items/guide.html.erb | 1 - lib/data/recruitment_banners.yml | 35 ------------- test/integration/recruitment_banner_test.rb | 8 +-- .../helpers/recruitment_banner_helper_test.rb | 51 ------------------- 8 files changed, 5 insertions(+), 122 deletions(-) delete mode 100644 app/helpers/recruitment_banner_helper.rb delete mode 100644 lib/data/recruitment_banners.yml delete mode 100644 test/unit/helpers/recruitment_banner_helper_test.rb diff --git a/app/helpers/recruitment_banner_helper.rb b/app/helpers/recruitment_banner_helper.rb deleted file mode 100644 index c7eb0f3e9..000000000 --- a/app/helpers/recruitment_banner_helper.rb +++ /dev/null @@ -1,27 +0,0 @@ -module RecruitmentBannerHelper - def recruitment_banner - return false if recruitment_banners.nil? - - current_path = request.path - - recruitment_banners.find do |banner| - next unless valid?(banner) - - banner["page_paths"]&.include?(current_path) - end - end - - def recruitment_banners - recruitment_banners_urls_file_path = Rails.root.join("lib/data/recruitment_banners.yml") - recruitment_banners_data = YAML.load_file(recruitment_banners_urls_file_path) - recruitment_banners_data["banners"] - end - - def valid?(banner) - required_fields.select { |field| banner[field].present? } == required_fields - end - - def required_fields - %w[survey_url suggestion_text suggestion_link_text page_paths] - end -end diff --git a/app/views/content_items/answer.html.erb b/app/views/content_items/answer.html.erb index f581b025d..8f0ba9500 100644 --- a/app/views/content_items/answer.html.erb +++ b/app/views/content_items/answer.html.erb @@ -5,5 +5,4 @@ <%= @requested_variant.analytics_meta_tag.html_safe if @requested_variant.present? %> <% end %> -<%= render 'shared/intervention_banner' %> <%= render 'content_items/body_with_related_links' %> diff --git a/app/views/content_items/detailed_guide.html.erb b/app/views/content_items/detailed_guide.html.erb index 9c81cf657..5450fe1af 100644 --- a/app/views/content_items/detailed_guide.html.erb +++ b/app/views/content_items/detailed_guide.html.erb @@ -3,7 +3,6 @@ schema: :faq ) %> <% end %> -<%= render 'shared/intervention_banner' %> <%= render 'shared/email_subscribe_unsubscribe_flash', { title: @content_item.title_and_context[:title] } %> diff --git a/app/views/content_items/document_collection.html.erb b/app/views/content_items/document_collection.html.erb index 9dcd15443..77208678b 100644 --- a/app/views/content_items/document_collection.html.erb +++ b/app/views/content_items/document_collection.html.erb @@ -6,7 +6,6 @@ <%= render 'shared/email_subscribe_unsubscribe_flash', { title: @content_item.title_and_context[:title] } %> -<%= render 'shared/intervention_banner' %>
<%= render 'govuk_publishing_components/components/title', @@ -32,7 +31,7 @@ <% if @content_item.important_metadata.any? %> <%= content_tag :div, class: "important-metadata inverse-background responsive-bottom-margin" do %> <%= render "govuk_publishing_components/components/metadata", { - inverse: true, + inverse: true, other: @content_item.important_metadata, margin_bottom: 0, } %> diff --git a/app/views/content_items/guide.html.erb b/app/views/content_items/guide.html.erb index 36be7b1b6..5d7f99420 100644 --- a/app/views/content_items/guide.html.erb +++ b/app/views/content_items/guide.html.erb @@ -18,7 +18,6 @@ <% content_for :simple_header, true %>
- <%= render 'shared/intervention_banner' %>
<%= render 'govuk_publishing_components/components/title', { title: @content_item.content_title } %> <% if @content_item.show_guide_navigation? %> diff --git a/lib/data/recruitment_banners.yml b/lib/data/recruitment_banners.yml deleted file mode 100644 index 645afde32..000000000 --- a/lib/data/recruitment_banners.yml +++ /dev/null @@ -1,35 +0,0 @@ -# Example usage of adding a banner to the banners list: - - # - name: Banner 1 - # suggestion_text: "Help improve GOV.UK" - # suggestion_link_text: "Sign up to take part in user research (opens in a new tab)" - # survey_url: https://google.com - # page_paths: - # - / - # - /foreign-travel-advice - -banners: -- name: AI banner 11/11/2024 - suggestion_text: "Help improve GOV.UK" - suggestion_link_text: "Sign up to take part in user research (opens in a new tab)" - survey_url: https://survey.take-part-in-research.service.gov.uk/jfe/form/SV_2bggmg6xlelrO0S - page_paths: - - /self-assessment-tax-returns - - /working-for-yourself - - /self-employed-records - - /expenses-if-youre-self-employed - - /first-company-accounts-and-return - - /what-is-the-construction-industry-scheme - - /capital-allowances - - /simpler-income-tax-cash-basis - - /expenses-and-benefits-a-to-z - - /capital-gains-tax - - /directors-loans - - /self-assessment-tax-return-forms - - /running-a-limited-company - - /calculate-tax-on-company-cars - - /introduction-to-business-rates - - /calculate-your-business-rates - - /apply-for-business-rate-relief - - /stop-being-self-employed - - /tax-codes diff --git a/test/integration/recruitment_banner_test.rb b/test/integration/recruitment_banner_test.rb index 4abf5d87b..88fcb14ce 100644 --- a/test/integration/recruitment_banner_test.rb +++ b/test/integration/recruitment_banner_test.rb @@ -24,8 +24,8 @@ class RecruitmentBannerTest < ActionDispatch::IntegrationTest stub_content_store_has_item(content_item["base_path"], content_item.to_json) visit content_item["base_path"] - assert page.has_css?(".gem-c-intervention") - assert page.has_link?("Sign up to take part in user research (opens in a new tab)", href: "https://survey.take-part-in-research.service.gov.uk/jfe/form/SV_2bggmg6xlelrO0S") + assert_not page.has_css?(".gem-c-intervention") + assert_not page.has_link?("Sign up to take part in user research (opens in a new tab)", href: "https://survey.take-part-in-research.service.gov.uk/jfe/form/SV_2bggmg6xlelrO0S") end end @@ -47,8 +47,8 @@ class RecruitmentBannerTest < ActionDispatch::IntegrationTest stub_content_store_has_item(content_item["base_path"], content_item.to_json) visit content_item["base_path"] - assert page.has_css?(".gem-c-intervention") - assert page.has_link?("Sign up to take part in user research (opens in a new tab)", href: "https://survey.take-part-in-research.service.gov.uk/jfe/form/SV_2bggmg6xlelrO0S") + assert_not page.has_css?(".gem-c-intervention") + assert_not page.has_link?("Sign up to take part in user research (opens in a new tab)", href: "https://survey.take-part-in-research.service.gov.uk/jfe/form/SV_2bggmg6xlelrO0S") end end diff --git a/test/unit/helpers/recruitment_banner_helper_test.rb b/test/unit/helpers/recruitment_banner_helper_test.rb deleted file mode 100644 index 3c261853f..000000000 --- a/test/unit/helpers/recruitment_banner_helper_test.rb +++ /dev/null @@ -1,51 +0,0 @@ -require "test_helper" - -class RecruitmentBannerHelperTest < ActionView::TestCase - include RecruitmentBannerHelper - - def setup - @recruitment_banners_data = YAML.load_file(Rails.root.join("test/fixtures/recruitment_banners.yml")) - end - - def request - OpenStruct.new(path: "/") - end - - def recruitment_banners - @recruitment_banners_data["banners"] - end - - test "recruitment_banner returns banners that include the current url" do - actual_banners = recruitment_banner - - expected_banners = - { - "name" => "Banner 1", - "suggestion_text" => "Help improve GOV.UK", - "suggestion_link_text" => "Take part in user research", - "survey_url" => "https://google.com", - "page_paths" => ["/"], - } - assert_equal expected_banners, actual_banners - end - - test "recruitment_banners yaml structure is valid" do - @recruitment_banners_data = YAML.load_file(Rails.root.join("lib/data/recruitment_banners.yml")) - - if @recruitment_banners_data["banners"].present? - recruitment_banners.each do |banner| - assert banner.key?("suggestion_text"), "Banner is missing 'suggestion_text' key" - assert_not banner["suggestion_text"].blank?, "'suggestion_text' key should not be blank" - - assert banner.key?("suggestion_link_text"), "Banner is missing 'suggestion_link_text' key" - assert_not banner["suggestion_link_text"].blank?, "'suggestion_link_text' key should not be blank" - - assert banner.key?("survey_url"), "Banner is missing 'survey_url' key" - assert_not banner["survey_url"].blank?, "'survey_url' key should not be blank" - - assert banner.key?("page_paths"), "Banner is missing 'page_paths' key" - assert_not banner["page_paths"].blank?, "'page_paths' key should not be blank" - end - end - end -end