From fd38b77a33dddf4dd16aa97c005c47eb01e7eaa2 Mon Sep 17 00:00:00 2001 From: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com> Date: Wed, 6 Jan 2021 13:24:14 -0700 Subject: [PATCH] Remove Collective Noun-Related Fields from SiteConfig (#12069) [deploy] * Removes collective_noun and collective_noun_disabled from SiteConfig * Adds a data_update script to remove collective_noun fields from Config * Adds additional guard clauses to collective noun scripts * Adds an unfinished spec around the removal of collective_noun fields * Reworks remove_collective_noun_from_site_config_spec test and expectations * Reverts changes to data_update script and removal of Config fields * Remove safe navigator from data_update script --- ..._remove_collective_noun_from_site_config.rb | 7 +++++++ ...ve_collective_noun_from_site_config_spec.rb | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 lib/data_update_scripts/20201229230456_remove_collective_noun_from_site_config.rb create mode 100644 spec/lib/data_update_scripts/remove_collective_noun_from_site_config_spec.rb diff --git a/lib/data_update_scripts/20201229230456_remove_collective_noun_from_site_config.rb b/lib/data_update_scripts/20201229230456_remove_collective_noun_from_site_config.rb new file mode 100644 index 000000000..4e9360105 --- /dev/null +++ b/lib/data_update_scripts/20201229230456_remove_collective_noun_from_site_config.rb @@ -0,0 +1,7 @@ +module DataUpdateScripts + class RemoveCollectiveNounFromSiteConfig + def run + SiteConfig.where(var: %w[collective_noun collective_noun_disabled]).destroy_all + end + end +end diff --git a/spec/lib/data_update_scripts/remove_collective_noun_from_site_config_spec.rb b/spec/lib/data_update_scripts/remove_collective_noun_from_site_config_spec.rb new file mode 100644 index 000000000..12b627845 --- /dev/null +++ b/spec/lib/data_update_scripts/remove_collective_noun_from_site_config_spec.rb @@ -0,0 +1,18 @@ +require "rails_helper" +require Rails.root.join( + "lib/data_update_scripts/20201229230456_remove_collective_noun_from_site_config.rb", +) + +describe DataUpdateScripts::RemoveCollectiveNounFromSiteConfig do + context "when collective_noun and collective_noun_disabled are removed from the Config" do + it "does not alter the community_name" do + allow(SiteConfig).to receive(:community_name).and_return("DEV Club") + + expect do + described_class.new.run + end.not_to change(SiteConfig, :community_name) + + expect(SiteConfig.community_name).to eq("DEV Club") + end + end +end