Adds collective_noun Fields Back to SiteConfig Model (#12055) [deploy]
* Adds collective_noun and collective_noun_disabled back to SiteConfig model * Adds a script that appends collective_noun conditionally and matching spec * Adds a conditional to determine if collective_noun should be appended * Refactors data_update script logic to be cleaner * Refactors spec to use method stubs * Adds a comment to the SiteConfig model about collective_noun fields * Adds an additional check to the scripts return statement
This commit is contained in:
parent
75fd3cb2a8
commit
6b0626a5e2
3 changed files with 36 additions and 0 deletions
|
|
@ -55,6 +55,10 @@ class SiteConfig < RailsSettings::Base
|
|||
# Community Content
|
||||
field :community_name, type: :string, default: ApplicationConfig["COMMUNITY_NAME"] || "New Forem"
|
||||
field :community_emoji, type: :string, default: "🌱"
|
||||
# collective_noun and collective_noun_disabled have been added back temporarily for
|
||||
# a data_update script, but will be removed in a future PR!
|
||||
field :collective_noun, type: :string, default: "Community"
|
||||
field :collective_noun_disabled, type: :boolean, default: false
|
||||
field :community_description, type: :string
|
||||
field :community_member_label, type: :string, default: "user"
|
||||
field :tagline, type: :string
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
module DataUpdateScripts
|
||||
class AppendCollectiveNounToCommunityName
|
||||
def run
|
||||
return if SiteConfig.collective_noun_disabled || SiteConfig.collective_noun.blank?
|
||||
|
||||
SiteConfig.community_name = "#{SiteConfig.community_name} #{SiteConfig.collective_noun}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
require "rails_helper"
|
||||
require Rails.root.join(
|
||||
"lib/data_update_scripts/20201228194641_append_collective_noun_to_community_name.rb",
|
||||
)
|
||||
|
||||
describe DataUpdateScripts::AppendCollectiveNounToCommunityName do
|
||||
context "when collective_noun_disabled is false" do
|
||||
it "appends the collective_noun to the community_name" do
|
||||
allow(SiteConfig).to receive(:collective_noun).and_return("Club")
|
||||
described_class.new.run
|
||||
expect(SiteConfig.collective_noun_disabled).to eq(false)
|
||||
expect(SiteConfig.community_name).to eq("DEV(local) Club")
|
||||
end
|
||||
end
|
||||
|
||||
context "when collective_noun_disabled is true" do
|
||||
it "does not append the collective_noun to the community_name" do
|
||||
allow(SiteConfig).to receive(:collective_noun_disabled).and_return(true)
|
||||
described_class.new.run
|
||||
expect(SiteConfig.community_name).to eq("DEV(local)")
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue