diff --git a/actionmailer/CHANGELOG.md b/actionmailer/CHANGELOG.md index 68d7c7db93..96cfb43e0b 100644 --- a/actionmailer/CHANGELOG.md +++ b/actionmailer/CHANGELOG.md @@ -1,12 +1,5 @@ ## Rails 4.0.0 (unreleased) ## -* Prevent mail from being delievered within the mailer actions by setting `perform_deliveries: false` *Aditya Sanghi* - - mail :to => user.email, :subject => "Campaign", :perform_deliveries => user.sendable? - - Global perform_deliveries flag when set to false is not overridden however. This allows you to stop some emails - from being delivered based on Spam Content/Unsubscribed User criterion from within the mailer action. - * Allow to set default Action Mailer options via `config.action_mailer.default_options=` *Robert Pankowecki* * Raise an `ActionView::MissingTemplate` exception when no implicit template could be found. *Damien Mathieu* diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 73ac8ea12b..900da9697e 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -683,7 +683,7 @@ module ActionMailer #:nodoc: m.charset = charset = headers[:charset] # Set configure delivery behavior - wrap_delivery_behavior!(headers.delete(:delivery_method),headers.delete(:perform_deliveries)) + wrap_delivery_behavior!(headers.delete(:delivery_method)) # Assign all headers except parts_order, content_type and body assignable = headers.except(:parts_order, :content_type, :body, :template_name, :template_path) diff --git a/actionmailer/lib/action_mailer/delivery_methods.rb b/actionmailer/lib/action_mailer/delivery_methods.rb index 0b8d0019eb..3b38dbccc7 100644 --- a/actionmailer/lib/action_mailer/delivery_methods.rb +++ b/actionmailer/lib/action_mailer/delivery_methods.rb @@ -57,7 +57,7 @@ module ActionMailer self.delivery_methods = delivery_methods.merge(symbol.to_sym => klass).freeze end - def wrap_delivery_behavior(mail, method=nil, perform_deliveries_header=nil) #:nodoc: + def wrap_delivery_behavior(mail, method=nil) #:nodoc: method ||= self.delivery_method mail.delivery_handler = self @@ -74,7 +74,7 @@ module ActionMailer mail.delivery_method(method) end - mail.perform_deliveries = perform_deliveries && (perform_deliveries_header.nil? || perform_deliveries_header) + mail.perform_deliveries = perform_deliveries mail.raise_delivery_errors = raise_delivery_errors end end diff --git a/actionmailer/test/delivery_methods_test.rb b/actionmailer/test/delivery_methods_test.rb index 886e79aae9..08f84dbf3b 100644 --- a/actionmailer/test/delivery_methods_test.rb +++ b/actionmailer/test/delivery_methods_test.rb @@ -82,7 +82,6 @@ class MailDeliveryTest < ActiveSupport::TestCase def welcome(hash={}) mail(DEFAULT_HEADERS.merge(hash)) end - end def setup @@ -130,18 +129,6 @@ class MailDeliveryTest < ActiveSupport::TestCase DeliveryMailer.welcome.deliver end - test "does not perform deliveries if customized per instance" do - DeliveryMailer.perform_deliveries = true - m = DeliveryMailer.welcome(:perform_deliveries => false) - assert_equal(false,m.perform_deliveries) - end - - test "does not perform deliveries if globally set to off but instance instructs delivery" do - DeliveryMailer.perform_deliveries = false - m = DeliveryMailer.welcome(:perform_deliveries => true) - assert_equal(false,m.perform_deliveries) - end - test "does not append the deliveries collection if told not to perform the delivery" do DeliveryMailer.perform_deliveries = false DeliveryMailer.deliveries.clear