Skip to content

Commit 6f029a8

Browse files
committed
Add regression check for mailer with global job is and fix swapped argument bug
1 parent 29a0f93 commit 6f029a8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/rspec/rails/matchers/have_enqueued_mail.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def deserialize_arguments(job)
145145
if hash.key?("_aj_ruby2_keywords")
146146
keywords = hash["_aj_ruby2_keywords"]
147147

148-
original_hash = keywords.each_with_object({}) { |new_hash, keyword| new_hash[keyword.to_sym] = hash[keyword] }
148+
original_hash = keywords.each_with_object({}) { |keyword, new_hash| new_hash[keyword.to_sym] = hash[keyword] }
149149

150150
args + [original_hash]
151151
elsif hash.key?(:args) && hash.key?(:params)

spec/rspec/rails/matchers/have_enqueued_mail_spec.rb

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
require "action_mailer"
55
require "rspec/rails/matchers/have_enqueued_mail"
66

7+
class GlobalIDArgument
8+
include GlobalID::Identification
9+
def id; 1; end
10+
def to_global_id(options = {}); super(options.merge(app: 'rspec-rails')); end
11+
end
12+
713
class TestMailer < ActionMailer::Base
814
def test_email; end
915
def email_with_args(arg1, arg2); end
@@ -413,6 +419,12 @@ def self.name; "NonMailerJob"; end
413419
)
414420
end
415421

422+
it "passes when given a global id serialised argument" do
423+
expect {
424+
UnifiedMailer.with(inquiry: GlobalIDArgument.new).test_email.deliver_later
425+
}.to have_enqueued_email(UnifiedMailer, :test_email)
426+
end
427+
416428
it "passes when using a mailer with `delivery_job` set to a sub class of `ActionMailer::DeliveryJob`" do
417429
expect {
418430
UnifiedMailerWithDeliveryJobSubClass.test_email.deliver_later

0 commit comments

Comments
 (0)