aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2019-03-01 14:07:59 -0800
committerJohn Hawthorn <john@hawthorn.email>2019-03-01 14:07:59 -0800
commit4e6c8045c3c5f7b914040c3bbb2cbbd901f45854 (patch)
tree3d167db8ed291e90a8691597e35ac67b49ee16d1 /actionmailer/lib
parented6364f7b6579a890c5cedc3c9e5b2f8af586e9e (diff)
downloadrails-4e6c8045c3c5f7b914040c3bbb2cbbd901f45854.tar.gz
rails-4e6c8045c3c5f7b914040c3bbb2cbbd901f45854.tar.bz2
rails-4e6c8045c3c5f7b914040c3bbb2cbbd901f45854.zip
Add test and change how format set in ActionMailer
Previously this used self.formats= to set the format which render would use to find templates. This worked, but was untested, and looked a little confusing because it was doing the mutation within a loop. This commit replaces the assignment with passing formats: [format] into the render call, which makes it more obvious that that's the purpose of the format. It also adds a test to verify the formats being used.
Diffstat (limited to 'actionmailer/lib')
-rw-r--r--actionmailer/lib/action_mailer/base.rb3
1 files changed, 1 insertions, 2 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index 8595b1e063..5b6e7121b3 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -974,9 +974,8 @@ module ActionMailer
each_template(Array(templates_path), templates_name).map do |template|
format = template.format || self.formats.first
- self.formats = [format]
{
- body: render(template: template),
+ body: render(template: template, formats: [format]),
content_type: Mime[format].to_s
}
end