diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-06-15 14:13:34 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-06-15 14:17:00 +0200 |
commit | f59ed560ac68aad47e56b6b0442b0b855ae9951e (patch) | |
tree | a2b15a915bb75c99e7c1d5f4e37705b99f2cdf58 /railties/test/application | |
parent | a15704d7f35f17d34d0118546799141d6f853656 (diff) | |
download | rails-f59ed560ac68aad47e56b6b0442b0b855ae9951e.tar.gz rails-f59ed560ac68aad47e56b6b0442b0b855ae9951e.tar.bz2 rails-f59ed560ac68aad47e56b6b0442b0b855ae9951e.zip |
allow preview interceptors to be registered through `config.action_mailer`.
This was partially broken because `preview_interceptors=` just assigned the
raw values, whithout going through `register_preview_interceptor`. Now the
Action Mailer railtie takes care of the `preview_interceptors` option.
This commit is a partial revert of:
Revert "Merge pull request #15739 from y-yagi/correct_doc_for_action_mailer_base"
This reverts commit a15704d7f35f17d34d0118546799141d6f853656, reversing
changes made to 1bd12a8609d275ad75fcc4b622ca4f5b32dc76be.
/cc @kuldeepaggarwal @y-yagi
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/configuration_test.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index e95c3fa20d..207a0c7e86 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -8,6 +8,12 @@ end class ::MyOtherMailInterceptor < ::MyMailInterceptor; end +class ::MyPreviewMailInterceptor + def self.previewing_email(email); email; end +end + +class ::MyOtherPreviewMailInterceptor < ::MyPreviewMailInterceptor; end + class ::MyMailObserver def self.delivered_email(email); email; end end @@ -460,6 +466,32 @@ module ApplicationTests assert_equal [::MyMailInterceptor, ::MyOtherMailInterceptor], ::Mail.send(:class_variable_get, "@@delivery_interceptors") end + test "registers preview interceptors with ActionMailer" do + add_to_config <<-RUBY + config.action_mailer.preview_interceptors = MyPreviewMailInterceptor + RUBY + + require "#{app_path}/config/environment" + require "mail" + + _ = ActionMailer::Base + + assert_equal [::MyPreviewMailInterceptor], ActionMailer::Base.preview_interceptors + end + + test "registers multiple preview interceptors with ActionMailer" do + add_to_config <<-RUBY + config.action_mailer.preview_interceptors = [MyPreviewMailInterceptor, "MyOtherPreviewMailInterceptor"] + RUBY + + require "#{app_path}/config/environment" + require "mail" + + _ = ActionMailer::Base + + assert_equal [MyPreviewMailInterceptor, MyOtherPreviewMailInterceptor], ActionMailer::Base.preview_interceptors + end + test "registers observers with ActionMailer" do add_to_config <<-RUBY config.action_mailer.observers = MyMailObserver |