Skip to content

Commit 6fd11ab

Browse files
committed
Merge pull request #2578 from rspec/have-enqueued-mail-fix
Fix have_enqueued_mail with global id arguments
1 parent 4ded7a4 commit 6fd11ab

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
@@ -418,6 +424,12 @@ def self.name; "NonMailerJob"; end
418424
)
419425
end
420426

427+
it "passes when given a global id serialised argument" do
428+
expect {
429+
UnifiedMailer.with(inquiry: GlobalIDArgument.new).test_email.deliver_later
430+
}.to have_enqueued_email(UnifiedMailer, :test_email)
431+
end
432+
421433
it "passes when using a mailer with `delivery_job` set to a sub class of `ActionMailer::DeliveryJob`" do
422434
expect {
423435
UnifiedMailerWithDeliveryJobSubClass.test_email.deliver_later

0 commit comments

Comments
 (0)