From b0a3adfd2656292d072f0da37db4f256ba43745a Mon Sep 17 00:00:00 2001 From: Jessica Jones Date: Fri, 20 Dec 2024 15:35:19 +0000 Subject: [PATCH] Remove old recruitment banner code --- app/helpers/recruitment_banner_helper.rb | 27 ----------- .../shared/_intervention_banner.html.erb | 10 ---- lib/data/recruitment_banners.yml | 11 ----- spec/fixtures/recruitment_banners.yml | 14 ------ .../helpers/recruitment_banner_helper_spec.rb | 46 ------------------- 5 files changed, 108 deletions(-) delete mode 100644 app/helpers/recruitment_banner_helper.rb delete mode 100644 app/views/shared/_intervention_banner.html.erb delete mode 100644 lib/data/recruitment_banners.yml delete mode 100644 spec/fixtures/recruitment_banners.yml delete mode 100644 spec/helpers/recruitment_banner_helper_spec.rb diff --git a/app/helpers/recruitment_banner_helper.rb b/app/helpers/recruitment_banner_helper.rb deleted file mode 100644 index c7eb0f3e9e..0000000000 --- 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/shared/_intervention_banner.html.erb b/app/views/shared/_intervention_banner.html.erb deleted file mode 100644 index 874c5f5130..0000000000 --- a/app/views/shared/_intervention_banner.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -<% if recruitment_banner.present? %> -
- <%= render "govuk_publishing_components/components/intervention", { - new_tab: true, - suggestion_text: recruitment_banner["suggestion_text"], - suggestion_link_text: recruitment_banner["suggestion_link_text"], - suggestion_link_url: recruitment_banner["survey_url"], - } %> -
-<% end %> diff --git a/lib/data/recruitment_banners.yml b/lib/data/recruitment_banners.yml deleted file mode 100644 index 1cff13a8db..0000000000 --- a/lib/data/recruitment_banners.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Example usage of adding a banner to the banners list: - - # - name: Banner 1 - # suggestion_text: "Help improve GOV.UK" - # suggestion_link_text: "Take part in user research" - # survey_url: https://google.com - # page_paths: - # - / - # - /foreign-travel-advice - -banners: diff --git a/spec/fixtures/recruitment_banners.yml b/spec/fixtures/recruitment_banners.yml deleted file mode 100644 index d0a1cf5cd3..0000000000 --- a/spec/fixtures/recruitment_banners.yml +++ /dev/null @@ -1,14 +0,0 @@ -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: - - / - - - name: Banner 2 - suggestion_text: "Help improve GOV.UK" - suggestion_link_text: "Take part in user research" - survey_url: https://google.com - page_paths: - - /some_path diff --git a/spec/helpers/recruitment_banner_helper_spec.rb b/spec/helpers/recruitment_banner_helper_spec.rb deleted file mode 100644 index 0d01cae166..0000000000 --- a/spec/helpers/recruitment_banner_helper_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -RSpec.describe RecruitmentBannerHelper do - include RecruitmentBannerHelper - - before do - @recruitment_banners_data = YAML.load_file(Rails.root.join("spec/fixtures/recruitment_banners.yml")) - end - - def request - OpenStruct.new(path: "/") - end - - def recruitment_banners - @recruitment_banners_data["banners"] - end - - describe "#recruitment_banner" do - it "returns banners that include the current url" do - 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" => ["/"], - } - - expect(recruitment_banner).to eq(expected_banners) - end - end - - it "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| - expect(banner.key?("suggestion_text")).to be true - expect(banner["suggestion_text"]).not_to be_empty - expect(banner.key?("suggestion_link_text")).to be true - expect(banner["suggestion_link_text"]).not_to be_empty - expect(banner.key?("survey_url")).to be true - expect(banner["survey_url"]).not_to be_empty - expect(banner.key?("page_paths")).to be true - expect(banner["page_paths"]).not_to be_empty - end - end - end -end