diff options
author | Robert Pankowecki <robert.pankowecki@gmail.com> | 2012-06-15 17:20:47 +0000 |
---|---|---|
committer | Robert Pankowecki <robert.pankowecki@gmail.com> | 2012-07-03 22:14:08 +0000 |
commit | edaa2c48179681efd96d0cad4b5dea696a2a31fb (patch) | |
tree | 7c73de0aa021eb631ce39ece2f04fd98cc87a1a8 /actionmailer/test | |
parent | b7a4fe18f2cee1385e7dcd36016fb6a15b93aef6 (diff) | |
download | rails-edaa2c48179681efd96d0cad4b5dea696a2a31fb.tar.gz rails-edaa2c48179681efd96d0cad4b5dea696a2a31fb.tar.bz2 rails-edaa2c48179681efd96d0cad4b5dea696a2a31fb.zip |
Introduce config.action_mailer.default_from=
Allows to easily set :from, :replay_to, etc. options in
config/application.rb using simple syntax:
config.action_mailer.default_options = {from:"no-replay@example.org"}
This was not possible using #default method because
config.action_mailer.default(from: "no-replay@example.org")
is interpreated as reader method and just returns nil.
It would not call ActionMailer::Base.default method. The only
way of calling this method from config/application.rb was to use
the direct syntax which looks ugly in my opinion:
config.assets.enabled = false
config.assets.version = '1.0'
config.encoding = "utf-8"
config.action_mailer.default_url_options= {
host:"example.org",
protocol:"https"
}
ActionMailer::Base.default(from: "no-replay@example.org")
Diffstat (limited to 'actionmailer/test')
-rw-r--r-- | actionmailer/test/base_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 144a6bfe39..9d1b1fda33 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -653,6 +653,19 @@ class BaseTest < ActiveSupport::TestCase assert_equal "Anonymous mailer body", mailer.welcome.body.encoded.strip end + test "default_from can be set" do + class DefaultFromMailer < ActionMailer::Base + default :to => 'system@test.lindsaar.net' + self.default_options = {from: "robert.pankowecki@gmail.com"} + + def welcome + mail(subject: "subject") + end + end + + assert_equal ["robert.pankowecki@gmail.com"], DefaultFromMailer.welcome.from + end + protected # Execute the block setting the given values and restoring old values after |