Skip to content

Commit

Permalink
Fix export when smtp settings are nil (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
armandfardeau committed Jul 21, 2023
1 parent c516315 commit ff74b79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/decidim_app/k8s/organization_exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ def omniauth_settings
end

def smtp_settings
settings = @organization.smtp_settings.deep_dup
settings["password"] = Decidim::AttributeEncryptor.decrypt(settings["encrypted_password"])
settings = @organization.smtp_settings.deep_dup || {}
settings["password"] = Decidim::AttributeEncryptor.decrypt(settings["encrypted_password"]) if settings["encrypted_password"].present?
settings.delete("encrypted_password")

settings = settings.transform_keys do |key|
Expand Down
10 changes: 10 additions & 0 deletions spec/lib/decidim_app/k8s/organization_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,16 @@
it "returns the smtp settings" do
expect(subject.smtp_settings).to eq({ "SMTP_ADDRESS" => "smtp.example.org", "SMTP_FROM" => "[email protected]", "SMTP_PASSWORD" => "demo", "SMTP_PORT" => "25", "SMTP_USER_NAME" => "test" })
end

context "when smtp settings are not present" do
before do
organization.update!(smtp_settings: nil)
end

it "returns empty smtp settings" do
expect(subject.smtp_settings).to eq({})
end
end
end

describe "#omniauth_settings" do
Expand Down

0 comments on commit ff74b79

Please sign in to comment.