From 73973d394176b047d582a1a8feb4e0607a8436d5 Mon Sep 17 00:00:00 2001 From: Molly Struve Date: Sun, 25 Apr 2021 13:59:54 -0400 Subject: [PATCH] Refactor:Remove jobs_url and Dispaly Banner (#13479) --- app/controllers/search_controller.rb | 6 +-- app/lib/constants/site_config.rb | 9 ---- app/models/site_config.rb | 4 -- app/views/admin/configs/show.html.erb | 33 --------------- app/views/articles/_search.html.erb | 4 -- spec/requests/admin/configs_spec.rb | 14 ------- spec/requests/search_spec.rb | 2 - .../system/search/display_jobs_banner_spec.rb | 41 ------------------- 8 files changed, 1 insertion(+), 112 deletions(-) delete mode 100644 spec/system/search/display_jobs_banner_spec.rb diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 51bdaf6a9..501fabc54 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -174,11 +174,7 @@ class SearchController < ApplicationController feed_content_search end - render json: { - result: result, - display_jobs_banner: SiteConfig.display_jobs_banner, - jobs_url: SiteConfig.jobs_url - } + render json: { result: result } end def reactions diff --git a/app/lib/constants/site_config.rb b/app/lib/constants/site_config.rb index 3d80ea19f..a9ff8df5e 100644 --- a/app/lib/constants/site_config.rb +++ b/app/lib/constants/site_config.rb @@ -45,11 +45,6 @@ module Constants default_font: { description: "Determines the default Base Reading Font (registered users can change this in their UX settings)" }, - display_jobs_banner: { - description: "Display a jobs banner that points users to the jobs page when they type 'job'" \ - "or 'jobs' in the search box", - placeholder: "" - }, email_addresses: { description: "Email address", placeholder: "" @@ -91,10 +86,6 @@ module Constants description: "Minimum score needed for a post to show up on the unauthenticated home page.", placeholder: "0" }, - jobs_url: { - description: "URL of the website where open positions are posted", - placeholder: "Jobs URL" - }, logo_png: { description: "Used as a fallback to the SVG. Recommended minimum of 512x512px for PWA support", placeholder: IMAGE_PLACEHOLDER diff --git a/app/models/site_config.rb b/app/models/site_config.rb index 5dba14b11..cfe34fcf3 100644 --- a/app/models/site_config.rb +++ b/app/models/site_config.rb @@ -76,10 +76,6 @@ class SiteConfig < RailsSettings::Base # Email digest frequency field :periodic_email_digest, type: :integer, default: 2 - # Jobs - field :jobs_url, type: :string - field :display_jobs_banner, type: :boolean, default: false - # Google Analytics Tracking ID, e.g. UA-71991000-1 field :ga_tracking_id, type: :string, default: ApplicationConfig["GA_TRACKING_ID"] diff --git a/app/views/admin/configs/show.html.erb b/app/views/admin/configs/show.html.erb index 055670896..b2c7d70d9 100644 --- a/app/views/admin/configs/show.html.erb +++ b/app/views/admin/configs/show.html.erb @@ -665,39 +665,6 @@ <% end %> - <%= form_for(SiteConfig.new, url: admin_config_path) do |f| %> -
- <%= render partial: "admin/shared/card_header", - locals: { - header: "Jobs", - state: "collapse", - target: "jobsBodyContainer", - expanded: false - } %> -
-
-
- <%= admin_config_label :jobs_url, "Jobs URL" %> - <%= admin_config_description Constants::SiteConfig::DETAILS[:jobs_url][:description] %> - <%= f.text_field :jobs_url, - class: "crayons-textfield", - value: SiteConfig.jobs_url, - placeholder: Constants::SiteConfig::DETAILS[:jobs_url][:placeholder] %> -
-
- <%= f.check_box :display_jobs_banner, checked: SiteConfig.display_jobs_banner, class: "crayons-checkbox" %> -
- <%= admin_config_label :display_jobs_banner %> - <%= admin_config_description Constants::SiteConfig::DETAILS[:display_jobs_banner][:description] %> -
-
- - <%= render "form_submission", f: f %> -
-
-
- <% end %> - <%= form_for(SiteConfig.new, url: admin_config_path) do |f| %>
<%= render partial: "admin/shared/card_header", diff --git a/app/views/articles/_search.html.erb b/app/views/articles/_search.html.erb index 94a65c216..f663445e7 100644 --- a/app/views/articles/_search.html.erb +++ b/app/views/articles/_search.html.erb @@ -167,10 +167,6 @@ }) .then(response => response.json()) .then((content) => { - if (searchHash["search_fields"] && content.jobs_url) { - addOptionalBanner(searchHash["search_fields"], content.display_jobs_banner, content.jobs_url); - } - var resultDivs = [] content.result.forEach(function (story, i) { resultDivs.push(buildArticleHTML(story)); diff --git a/spec/requests/admin/configs_spec.rb b/spec/requests/admin/configs_spec.rb index 7ea2a3e1d..1b6e9e1ae 100644 --- a/spec/requests/admin/configs_spec.rb +++ b/spec/requests/admin/configs_spec.rb @@ -311,20 +311,6 @@ RSpec.describe "/admin/config", type: :request do end end - describe "Jobs" do - it "updates jobs_url" do - post "/admin/config", params: { site_config: { jobs_url: "www.jobs.com" }, - confirmation: confirmation_message } - expect(SiteConfig.jobs_url).to eq("www.jobs.com") - end - - it "updates display_jobs_banner" do - post "/admin/config", params: { site_config: { display_jobs_banner: true }, - confirmation: confirmation_message } - expect(SiteConfig.display_jobs_banner).to eq(true) - end - end - describe "Google Analytics Reporting API v4" do it "updates ga_tracking_id" do post "/admin/config", params: { site_config: { ga_tracking_id: "abc" }, confirmation: confirmation_message } diff --git a/spec/requests/search_spec.rb b/spec/requests/search_spec.rb index 3d6c68280..083557e75 100644 --- a/spec/requests/search_spec.rb +++ b/spec/requests/search_spec.rb @@ -262,8 +262,6 @@ RSpec.describe "Search", type: :request, proper_status: true do get search_feed_content_path(class_name: "Article") expect(response.parsed_body["result"]).to be_present - expect(response.parsed_body["display_jobs_banner"]).to eq(SiteConfig.display_jobs_banner) - expect(response.parsed_body["jobs_url"]).to eq(SiteConfig.jobs_url) end it "parses published_at correctly", :aggregate_failures do diff --git a/spec/system/search/display_jobs_banner_spec.rb b/spec/system/search/display_jobs_banner_spec.rb deleted file mode 100644 index 9c294e88d..000000000 --- a/spec/system/search/display_jobs_banner_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require "rails_helper" - -RSpec.describe "Display Jobs Banner spec", type: :system, js: true, stub_elasticsearch: true do - before do - allow(SiteConfig).to receive(:jobs_url).and_return("www.very_cool_jobs_website.com") - end - - context "when SiteConfig.display_jobs_banner is false" do - it "does not show jobs banner" do - allow(SiteConfig).to receive(:display_jobs_banner).and_return(false) - visit "/search?q=jobs" - - expect(page).not_to have_content("Interested in joining our team?") - end - end - - context "when SiteConfig.display_jobs_banner is true" do - before { allow(SiteConfig).to receive(:display_jobs_banner).and_return(true) } - - it "displays job banner for job search" do - visit "/search?q=jobs" - - expect(page).to have_content("Interested in joining our team?") - expect(find_link("open roles")["href"]).to include(SiteConfig.jobs_url) - end - - it "does not display jobs banner for other searches" do - visit "/search?q=ruby" - - expect(page).not_to have_content("Interested in joining our team?") - end - - it "does not show jobs banner when there's no jobs_url set" do - allow(SiteConfig).to receive(:jobs_url).and_return(nil) - - visit "/search?q=jobs" - - expect(page).not_to have_content("Interested in joining our team?") - end - end -end