Skip to content

Commit

Permalink
Merge pull request #1167 from internetee/remove-hardcoded-default-ema…
Browse files Browse the repository at this point in the history
…il-sender

Remove hardcoded default email sender
  • Loading branch information
vohmar authored Apr 24, 2019
2 parents 29d7622 + a113d75 commit ee20535
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
1 change: 0 additions & 1 deletion app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class ApplicationMailer < ActionMailer::Base
append_view_path Rails.root.join('app', 'views', 'mailers')
default from: '[email protected]'
layout 'mailer'

def format(email)
Expand Down
2 changes: 2 additions & 0 deletions config/application-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ auction_api_allowed_ips: '' # 192.0.2.0, 192.0.2.1
action_mailer_default_protocol: # default: http
action_mailer_default_host:
action_mailer_default_port: # default: no port (80)
action_mailer_default_from: # [email protected]

# Since the keys for staging are absent from the repo, we need to supply them separate for testing.
test:
Expand All @@ -153,6 +154,7 @@ test:
release_domains_to_auction: 'false'
auction_api_allowed_ips: ''
action_mailer_default_host: 'registry.test'
action_mailer_default_from: '[email protected]'

# Airbrake // Errbit:
airbrake_host: "https://your-errbit-host.ee"
Expand Down
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class Application < Rails::Application
domain: ENV['smtp_domain'],
openssl_verify_mode: ENV['smtp_openssl_verify_mode']
}
config.action_mailer.default_options = { from: ENV['action_mailer_default_from'] }

config.action_view.default_form_builder = 'DefaultFormBuilder'
config.secret_key_base = Figaro.env.secret_key_base
Expand Down
1 change: 1 addition & 0 deletions config/initializers/figaro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
bank_statement_import_dir
time_zone
action_mailer_default_host
action_mailer_default_from
])
17 changes: 17 additions & 0 deletions test/mailers/application_mailer_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'test_helper'

class ApplicationMailerTest < ActiveSupport::TestCase
def test_reads_default_from_setting_from_config
assert_equal '[email protected]', ENV['action_mailer_default_from']

mailer = Class.new(ApplicationMailer) do
def test
# Empty block to avoid template rendering
mail {}
end
end
email = mailer.test

assert_equal ['[email protected]'], email.from
end
end

0 comments on commit ee20535

Please sign in to comment.