From f59ed560ac68aad47e56b6b0442b0b855ae9951e Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Sun, 15 Jun 2014 14:13:34 +0200 Subject: 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 --- railties/test/application/configuration_test.rb | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'railties') 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 -- cgit v1.2.3