feat: update the contact email address in the database (#11848)
This commit is contained in:
parent
563a2c5a22
commit
23235c2276
2 changed files with 44 additions and 0 deletions
|
|
@ -0,0 +1,9 @@
|
|||
module DataUpdateScripts
|
||||
class SetContactEmailAddress
|
||||
def run
|
||||
return if SiteConfig.email_addresses[:contact].present?
|
||||
|
||||
SiteConfig.email_addresses[:contact] = ApplicationConfig["DEFAULT_EMAIL"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
require "rails_helper"
|
||||
require Rails.root.join(
|
||||
"lib/data_update_scripts/20201210163704_set_contact_email_address.rb",
|
||||
)
|
||||
|
||||
describe DataUpdateScripts::SetContactEmailAddress do
|
||||
let(:contact_email) { "contact@dev.to" }
|
||||
|
||||
before do
|
||||
allow(SiteConfig).to receive(:email_addresses).and_return(
|
||||
{
|
||||
default: "hi@dev.to",
|
||||
business: "business@dev.to",
|
||||
privacy: "privacy@dev.to",
|
||||
members: "members@dev.to"
|
||||
},
|
||||
)
|
||||
end
|
||||
|
||||
context "with no contact email set in the email_addresses hash" do
|
||||
it "adds the contact email" do
|
||||
described_class.new.run
|
||||
expect(SiteConfig.email_addresses).to include(contact: ApplicationConfig["DEFAULT_EMAIL"])
|
||||
end
|
||||
end
|
||||
|
||||
context "with a contact email set in the email_addresses hash" do
|
||||
it "preserves the current contact email" do
|
||||
SiteConfig.email_addresses[:contact] = contact_email
|
||||
described_class.new.run
|
||||
SiteConfig.clear_cache
|
||||
expect(SiteConfig.email_addresses).to include(contact: contact_email)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue