From 75fa8dd309a84e125b59d01bf182d88419631eaa Mon Sep 17 00:00:00 2001
From: David Heinemeier Hansson <david@loudthinking.com>
Date: Thu, 18 May 2017 18:12:32 +0200
Subject: Use recyclable cache keys (#29092)

---
 actionmailer/test/caching_test.rb | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

(limited to 'actionmailer/test')

diff --git a/actionmailer/test/caching_test.rb b/actionmailer/test/caching_test.rb
index cff49c8894..5869eae7fd 100644
--- a/actionmailer/test/caching_test.rb
+++ b/actionmailer/test/caching_test.rb
@@ -21,10 +21,6 @@ class BaseCachingTest < ActiveSupport::TestCase
     @mailer.perform_caching = true
     @mailer.cache_store = @store
   end
-
-  def test_fragment_cache_key
-    assert_equal "views/what a key", @mailer.fragment_cache_key("what a key")
-  end
 end
 
 class FragmentCachingTest < BaseCachingTest
@@ -126,7 +122,7 @@ class FunctionalFragmentCachingTest < BaseCachingTest
 
     assert_match expected_body, email.body.encoded
     assert_match expected_body,
-      @store.read("views/caching/#{template_digest("caching_mailer/fragment_cache")}")
+      @store.read("views/caching_mailer/fragment_cache:#{template_digest("caching_mailer/fragment_cache")}/caching")
   end
 
   def test_fragment_caching_in_partials
@@ -135,7 +131,7 @@ class FunctionalFragmentCachingTest < BaseCachingTest
     assert_match(expected_body, email.body.encoded)
 
     assert_match(expected_body,
-      @store.read("views/caching/#{template_digest("caching_mailer/_partial")}"))
+      @store.read("views/caching_mailer/_partial:#{template_digest("caching_mailer/_partial")}/caching"))
   end
 
   def test_skip_fragment_cache_digesting
@@ -185,7 +181,7 @@ class FunctionalFragmentCachingTest < BaseCachingTest
     end
 
     assert_equal "caching_mailer", payload[:mailer]
-    assert_equal "views/caching/#{template_digest("caching_mailer/fragment_cache")}", payload[:key]
+    assert_equal [ :views, "caching_mailer/fragment_cache:#{template_digest("caching_mailer/fragment_cache")}", :caching ], payload[:key]
   ensure
     @mailer.enable_fragment_cache_logging = true
   end
-- 
cgit v1.2.3


From 40bdbce191ad90dfea43dad51fac5c4726b89392 Mon Sep 17 00:00:00 2001
From: bogdanvlviv <bogdanvlviv@gmail.com>
Date: Mon, 15 May 2017 14:17:28 +0000
Subject: Define path with __dir__

".. with __dir__ we can restore order in the Universe." - by @fxn

Related to 5b8738c2df003a96f0e490c43559747618d10f5f
---
 actionmailer/test/abstract_unit.rb       | 4 ++--
 actionmailer/test/caching_test.rb        | 2 +-
 actionmailer/test/log_subscriber_test.rb | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

(limited to 'actionmailer/test')

diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb
index a646cbd581..dbfdb07e6e 100644
--- a/actionmailer/test/abstract_unit.rb
+++ b/actionmailer/test/abstract_unit.rb
@@ -9,7 +9,7 @@ end
 
 module Rails
   def self.root
-    File.expand_path("../", File.dirname(__FILE__))
+    File.expand_path("..", __dir__)
   end
 end
 
@@ -28,7 +28,7 @@ ActiveSupport::Deprecation.debug = true
 # Disable available locale checks to avoid warnings running the test suite.
 I18n.enforce_available_locales = false
 
-FIXTURE_LOAD_PATH = File.expand_path("fixtures", File.dirname(__FILE__))
+FIXTURE_LOAD_PATH = File.expand_path("fixtures", __dir__)
 ActionMailer::Base.view_paths = FIXTURE_LOAD_PATH
 
 class ActiveSupport::TestCase
diff --git a/actionmailer/test/caching_test.rb b/actionmailer/test/caching_test.rb
index 5869eae7fd..e76466439e 100644
--- a/actionmailer/test/caching_test.rb
+++ b/actionmailer/test/caching_test.rb
@@ -5,7 +5,7 @@ require "mailers/caching_mailer"
 
 CACHE_DIR = "test_cache"
 # Don't change '/../temp/' cavalierly or you might hose something you don't want hosed
-FILE_STORE_PATH = File.join(File.dirname(__FILE__), "/../temp/", CACHE_DIR)
+FILE_STORE_PATH = File.join(__dir__, "/../temp/", CACHE_DIR)
 
 class FragmentCachingMailer < ActionMailer::Base
   abstract!
diff --git a/actionmailer/test/log_subscriber_test.rb b/actionmailer/test/log_subscriber_test.rb
index 7969782e07..799c6144d7 100644
--- a/actionmailer/test/log_subscriber_test.rb
+++ b/actionmailer/test/log_subscriber_test.rb
@@ -36,7 +36,7 @@ class AMLogSubscriberTest < ActionMailer::TestCase
   end
 
   def test_receive_is_notified
-    fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email")
+    fixture = File.read(File.expand_path("fixtures/raw_email", __dir__))
     TestMailer.receive(fixture)
     wait
     assert_equal(1, @logger.logged(:info).size)
-- 
cgit v1.2.3


From d9bbde09fc57b29b889baadda18da943428fb06a Mon Sep 17 00:00:00 2001
From: Matthew Mongeau <halogenandtoast@gmail.com>
Date: Thu, 15 Jun 2017 16:12:44 +0900
Subject: Allow mailers to configure their delivery job

Setting delivery_job on a mailer class will cause MessageDelivery to use
the specified job instead of ActionMailer::DeliveryJob:

    class MyMailer < ApplicationMailer
      self.delivery_job = MyCustomDeliveryJob

      ...
    end
---
 actionmailer/test/message_delivery_test.rb | 13 +++++++++++++
 1 file changed, 13 insertions(+)

(limited to 'actionmailer/test')

diff --git a/actionmailer/test/message_delivery_test.rb b/actionmailer/test/message_delivery_test.rb
index c0683be94d..51f10b0bf1 100644
--- a/actionmailer/test/message_delivery_test.rb
+++ b/actionmailer/test/message_delivery_test.rb
@@ -95,6 +95,19 @@ class MessageDeliveryTest < ActiveSupport::TestCase
     end
   end
 
+  test "should enqueue the job with the correct delivery job" do
+    old_delivery_job = DelayedMailer.delivery_job
+    DelayedMailer.delivery_job = DummyJob
+
+    assert_performed_with(job: DummyJob, args: ["DelayedMailer", "test_message", "deliver_now", 1, 2, 3]) do
+      @mail.deliver_later
+    end
+
+    DelayedMailer.delivery_job = old_delivery_job
+  end
+
+  class DummyJob < ActionMailer::DeliveryJob; end
+
   test "can override the queue when enqueuing mail" do
     assert_performed_with(job: ActionMailer::DeliveryJob, args: ["DelayedMailer", "test_message", "deliver_now", 1, 2, 3], queue: "another_queue") do
       @mail.deliver_later(queue: :another_queue)
-- 
cgit v1.2.3