aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib
diff options
context:
space:
mode:
authorJimmy Bourassa <jimmy.bourassa@hooktstudios.com>2017-08-24 01:13:54 -0400
committerJimmy Bourassa <jimmy.bourassa@hooktstudios.com>2017-08-29 09:42:28 -0400
commitfbb2fc8aa7d17fd86ad9c3fbbe60ef84a4cde950 (patch)
treecc7db1c38e4dc64c437b1be50d49192af826cfed /actionmailer/lib
parent9a66a22102db76896f400939165ec92280e092e7 (diff)
downloadrails-fbb2fc8aa7d17fd86ad9c3fbbe60ef84a4cde950.tar.gz
rails-fbb2fc8aa7d17fd86ad9c3fbbe60ef84a4cde950.tar.bz2
rails-fbb2fc8aa7d17fd86ad9c3fbbe60ef84a4cde950.zip
Fix AM::Base.default proc arity breaking change
PR #29270 changed the number of arguments that gets passed to Procs defined in ActionMail::Base.default. With this changeset, Procs can now have 1 or 0 arguments Also adds test coverage for AM::Base.default Proc arity.
Diffstat (limited to 'actionmailer/lib')
-rw-r--r--actionmailer/lib/action_mailer/base.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index a54eb52dcb..8477539c49 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -889,7 +889,7 @@ module ActionMailer
default_values = self.class.default.map do |key, value|
[
key,
- value.is_a?(Proc) ? instance_exec(&value) : value
+ compute_default(value)
]
end.to_h
@@ -898,6 +898,16 @@ module ActionMailer
headers_with_defaults
end
+ def compute_default(value)
+ return value unless value.is_a?(Proc)
+
+ if value.arity == 1
+ instance_exec(self, &value)
+ else
+ instance_exec(&value)
+ end
+ end
+
def assign_headers_to_message(message, headers)
assignable = headers.except(:parts_order, :content_type, :body, :template_name,
:template_path, :delivery_method, :delivery_method_options)