aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer
diff options
context:
space:
mode:
Diffstat (limited to 'actionmailer')
-rw-r--r--actionmailer/CHANGELOG.md5
-rw-r--r--actionmailer/README.rdoc4
-rw-r--r--actionmailer/actionmailer.gemspec2
-rw-r--r--actionmailer/lib/action_mailer/base.rb10
-rw-r--r--actionmailer/lib/action_mailer/gem_version.rb2
-rw-r--r--actionmailer/lib/action_mailer/log_subscriber.rb5
-rw-r--r--actionmailer/lib/action_mailer/mail_delivery_job.rb2
-rw-r--r--actionmailer/test/base_test.rb25
-rw-r--r--actionmailer/test/caching_test.rb10
-rw-r--r--actionmailer/test/fixtures/base_mailer/implicit_multipart_formats.html.erb1
-rw-r--r--actionmailer/test/fixtures/base_mailer/implicit_multipart_formats.text.erb1
-rw-r--r--actionmailer/test/log_subscriber_test.rb8
-rw-r--r--actionmailer/test/mailers/base_mailer.rb8
13 files changed, 60 insertions, 23 deletions
diff --git a/actionmailer/CHANGELOG.md b/actionmailer/CHANGELOG.md
index 806e428481..e9d8d07c79 100644
--- a/actionmailer/CHANGELOG.md
+++ b/actionmailer/CHANGELOG.md
@@ -1,3 +1,8 @@
+## Rails 6.0.0.beta2 (February 25, 2019) ##
+
+* No changes.
+
+
## Rails 6.0.0.beta1 (January 18, 2019) ##
* Deprecate `ActionMailer::Base.receive` in favor of [Action Mailbox](https://github.com/rails/rails/tree/master/actionmailbox).
diff --git a/actionmailer/README.rdoc b/actionmailer/README.rdoc
index 74d7ea65ce..0db4b2668b 100644
--- a/actionmailer/README.rdoc
+++ b/actionmailer/README.rdoc
@@ -13,6 +13,8 @@ Additionally, an Action Mailer class can be used to process incoming email,
such as allowing a blog to accept new posts from an email (which could even
have been sent from a phone).
+You can read more about Action Mailer in the {Action Mailer Basics}[https://edgeguides.rubyonrails.org/action_mailer_basics.html] guide.
+
== Sending emails
The framework works by initializing any instance variables you want to be
@@ -128,7 +130,7 @@ Action Mailer is released under the MIT license:
API documentation is at
-* http://api.rubyonrails.org
+* https://api.rubyonrails.org
Bug reports for the Ruby on Rails project can be filed here:
diff --git a/actionmailer/actionmailer.gemspec b/actionmailer/actionmailer.gemspec
index c76cb3ec72..cadccb905b 100644
--- a/actionmailer/actionmailer.gemspec
+++ b/actionmailer/actionmailer.gemspec
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
s.author = "David Heinemeier Hansson"
s.email = "david@loudthinking.com"
- s.homepage = "http://rubyonrails.org"
+ s.homepage = "https://rubyonrails.org"
s.files = Dir["CHANGELOG.md", "README.rdoc", "MIT-LICENSE", "lib/**/*"]
s.require_path = "lib"
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index 099e98131f..c1ac9c2ad1 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -593,6 +593,7 @@ module ActionMailer
private
def set_payload_for_mail(payload, mail)
+ payload[:mail] = mail.encoded
payload[:mailer] = name
payload[:message_id] = mail.message_id
payload[:subject] = mail.subject
@@ -601,7 +602,6 @@ module ActionMailer
payload[:bcc] = mail.bcc if mail.bcc.present?
payload[:cc] = mail.cc if mail.cc.present?
payload[:date] = mail.date
- payload[:mail] = mail.encoded
payload[:perform_deliveries] = mail.perform_deliveries
end
@@ -973,10 +973,10 @@ module ActionMailer
templates_name = headers[:template_name] || action_name
each_template(Array(templates_path), templates_name).map do |template|
- self.formats = template.formats
+ format = template.format || self.formats.first
{
- body: render(template: template),
- content_type: template.type.to_s
+ body: render(template: template, formats: [format]),
+ content_type: Mime[format].to_s
}
end
end
@@ -986,7 +986,7 @@ module ActionMailer
if templates.empty?
raise ActionView::MissingTemplate.new(paths, name, paths, false, "mailer")
else
- templates.uniq(&:formats).each(&block)
+ templates.uniq(&:format).each(&block)
end
end
diff --git a/actionmailer/lib/action_mailer/gem_version.rb b/actionmailer/lib/action_mailer/gem_version.rb
index 4cab52d1f3..3002fd2ad6 100644
--- a/actionmailer/lib/action_mailer/gem_version.rb
+++ b/actionmailer/lib/action_mailer/gem_version.rb
@@ -10,7 +10,7 @@ module ActionMailer
MAJOR = 6
MINOR = 0
TINY = 0
- PRE = "beta1"
+ PRE = "beta2"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
end
diff --git a/actionmailer/lib/action_mailer/log_subscriber.rb b/actionmailer/lib/action_mailer/log_subscriber.rb
index 25c99342c2..26910f20f0 100644
--- a/actionmailer/lib/action_mailer/log_subscriber.rb
+++ b/actionmailer/lib/action_mailer/log_subscriber.rb
@@ -10,11 +10,10 @@ module ActionMailer
def deliver(event)
info do
perform_deliveries = event.payload[:perform_deliveries]
- recipients = Array(event.payload[:to]).join(", ")
if perform_deliveries
- "Sent mail to #{recipients} (#{event.duration.round(1)}ms)"
+ "Delivered mail #{event.payload[:message_id]} (#{event.duration.round(1)}ms)"
else
- "Skipped sending mail to #{recipients} as `perform_deliveries` is false"
+ "Skipped delivery of mail #{event.payload[:message_id]} as `perform_deliveries` is false"
end
end
diff --git a/actionmailer/lib/action_mailer/mail_delivery_job.rb b/actionmailer/lib/action_mailer/mail_delivery_job.rb
index 93778edfce..609c6a72d9 100644
--- a/actionmailer/lib/action_mailer/mail_delivery_job.rb
+++ b/actionmailer/lib/action_mailer/mail_delivery_job.rb
@@ -3,7 +3,7 @@
require "active_job"
module ActionMailer
- # The <tt>ActionMailer::NewDeliveryJob</tt> class is used when you
+ # The <tt>ActionMailer::MailDeliveryJob</tt> class is used when you
# want to send emails outside of the request-response cycle. It supports
# sending either parameterized or normal mail.
#
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index d0c4f189fd..c07fca5b5e 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -307,6 +307,16 @@ class BaseTest < ActiveSupport::TestCase
assert_equal("HTML Implicit Multipart", email.parts[1].body.encoded)
end
+ test "implicit multipart formats" do
+ email = BaseMailer.implicit_multipart_formats
+ assert_equal(2, email.parts.size)
+ assert_equal("multipart/alternative", email.mime_type)
+ assert_equal("text/plain", email.parts[0].mime_type)
+ assert_equal("Implicit Multipart [:text]", email.parts[0].body.encoded)
+ assert_equal("text/html", email.parts[1].mime_type)
+ assert_equal("Implicit Multipart [:html]", email.parts[1].body.encoded)
+ end
+
test "implicit multipart with sort order" do
order = ["text/html", "text/plain"]
with_default BaseMailer, parts_order: order do
@@ -913,6 +923,21 @@ class BaseTest < ActiveSupport::TestCase
ActiveSupport::Notifications.unsubscribe "process.action_mailer"
end
+ test "notification for deliver" do
+ events = []
+ ActiveSupport::Notifications.subscribe("deliver.action_mailer") do |*args|
+ events << ActiveSupport::Notifications::Event.new(*args)
+ end
+
+ BaseMailer.welcome(body: "Hello there").deliver_now
+
+ assert_equal 1, events.length
+ assert_equal "deliver.action_mailer", events[0].name
+ assert_not_nil events[0].payload[:message_id]
+ ensure
+ ActiveSupport::Notifications.unsubscribe "deliver.action_mailer"
+ end
+
private
# Execute the block setting the given values and restoring old values after
diff --git a/actionmailer/test/caching_test.rb b/actionmailer/test/caching_test.rb
index 22f310f39f..b658c96ec7 100644
--- a/actionmailer/test/caching_test.rb
+++ b/actionmailer/test/caching_test.rb
@@ -124,7 +124,7 @@ class FunctionalFragmentCachingTest < BaseCachingTest
assert_match expected_body, email.body.encoded
assert_match expected_body,
- @store.read("views/caching_mailer/fragment_cache:#{template_digest("caching_mailer/fragment_cache")}/caching")
+ @store.read("views/caching_mailer/fragment_cache:#{template_digest("caching_mailer/fragment_cache", "html")}/caching")
end
def test_fragment_caching_in_partials
@@ -133,7 +133,7 @@ class FunctionalFragmentCachingTest < BaseCachingTest
assert_match(expected_body, email.body.encoded)
assert_match(expected_body,
- @store.read("views/caching_mailer/_partial:#{template_digest("caching_mailer/_partial")}/caching"))
+ @store.read("views/caching_mailer/_partial:#{template_digest("caching_mailer/_partial", "html")}/caching"))
end
def test_skip_fragment_cache_digesting
@@ -183,15 +183,15 @@ class FunctionalFragmentCachingTest < BaseCachingTest
end
assert_equal "caching_mailer", payload[:mailer]
- assert_equal [ :views, "caching_mailer/fragment_cache:#{template_digest("caching_mailer/fragment_cache")}", :caching ], payload[:key]
+ assert_equal [ :views, "caching_mailer/fragment_cache:#{template_digest("caching_mailer/fragment_cache", "html")}", :caching ], payload[:key]
ensure
@mailer.enable_fragment_cache_logging = true
end
private
- def template_digest(name)
- ActionView::Digestor.digest(name: name, finder: @mailer.lookup_context)
+ def template_digest(name, format)
+ ActionView::Digestor.digest(name: name, format: format, finder: @mailer.lookup_context)
end
end
diff --git a/actionmailer/test/fixtures/base_mailer/implicit_multipart_formats.html.erb b/actionmailer/test/fixtures/base_mailer/implicit_multipart_formats.html.erb
new file mode 100644
index 0000000000..0179b070b8
--- /dev/null
+++ b/actionmailer/test/fixtures/base_mailer/implicit_multipart_formats.html.erb
@@ -0,0 +1 @@
+Implicit Multipart <%= formats.inspect %> \ No newline at end of file
diff --git a/actionmailer/test/fixtures/base_mailer/implicit_multipart_formats.text.erb b/actionmailer/test/fixtures/base_mailer/implicit_multipart_formats.text.erb
new file mode 100644
index 0000000000..0179b070b8
--- /dev/null
+++ b/actionmailer/test/fixtures/base_mailer/implicit_multipart_formats.text.erb
@@ -0,0 +1 @@
+Implicit Multipart <%= formats.inspect %> \ No newline at end of file
diff --git a/actionmailer/test/log_subscriber_test.rb b/actionmailer/test/log_subscriber_test.rb
index fb569ce45f..f09f1997c0 100644
--- a/actionmailer/test/log_subscriber_test.rb
+++ b/actionmailer/test/log_subscriber_test.rb
@@ -24,11 +24,11 @@ class AMLogSubscriberTest < ActionMailer::TestCase
end
def test_deliver_is_notified
- BaseMailer.welcome.deliver_now
+ BaseMailer.welcome(message_id: "123@abc").deliver_now
wait
assert_equal(1, @logger.logged(:info).size)
- assert_match(/Sent mail to system@test\.lindsaar\.net/, @logger.logged(:info).first)
+ assert_match(/Delivered mail 123@abc/, @logger.logged(:info).first)
assert_equal(2, @logger.logged(:debug).size)
assert_match(/BaseMailer#welcome: processed outbound mail in [\d.]+ms/, @logger.logged(:debug).first)
@@ -38,11 +38,11 @@ class AMLogSubscriberTest < ActionMailer::TestCase
end
def test_deliver_message_when_perform_deliveries_is_false
- BaseMailer.welcome_without_deliveries.deliver_now
+ BaseMailer.welcome_without_deliveries(message_id: "123@abc").deliver_now
wait
assert_equal(1, @logger.logged(:info).size)
- assert_match("Skipped sending mail to system@test.lindsaar.net as `perform_deliveries` is false", @logger.logged(:info).first)
+ assert_match("Skipped delivery of mail 123@abc as `perform_deliveries` is false", @logger.logged(:info).first)
assert_equal(2, @logger.logged(:debug).size)
assert_match(/BaseMailer#welcome_without_deliveries: processed outbound mail in [\d.]+ms/, @logger.logged(:debug).first)
diff --git a/actionmailer/test/mailers/base_mailer.rb b/actionmailer/test/mailers/base_mailer.rb
index c1bb48cc96..6bd58304e2 100644
--- a/actionmailer/test/mailers/base_mailer.rb
+++ b/actionmailer/test/mailers/base_mailer.rb
@@ -21,8 +21,8 @@ class BaseMailer < ActionMailer::Base
mail(template_name: "welcome", template_path: path)
end
- def welcome_without_deliveries
- mail(template_name: "welcome")
+ def welcome_without_deliveries(hash = {})
+ mail({ template_name: "welcome" }.merge!(hash))
mail.perform_deliveries = false
end
@@ -62,6 +62,10 @@ class BaseMailer < ActionMailer::Base
mail(hash)
end
+ def implicit_multipart_formats(hash = {})
+ mail(hash)
+ end
+
def implicit_with_locale(hash = {})
mail(hash)
end