Skip to content

Commit

Permalink
Add regression check for mailer with global job is and fix swapped ar…
Browse files Browse the repository at this point in the history
…gument bug
  • Loading branch information
JonRowe committed Mar 7, 2022
1 parent 29a0f93 commit 6f029a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rspec/rails/matchers/have_enqueued_mail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def deserialize_arguments(job)
if hash.key?("_aj_ruby2_keywords")
keywords = hash["_aj_ruby2_keywords"]

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

args + [original_hash]
elsif hash.key?(:args) && hash.key?(:params)
Expand Down
12 changes: 12 additions & 0 deletions spec/rspec/rails/matchers/have_enqueued_mail_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
require "action_mailer"
require "rspec/rails/matchers/have_enqueued_mail"

class GlobalIDArgument
include GlobalID::Identification
def id; 1; end
def to_global_id(options = {}); super(options.merge(app: 'rspec-rails')); end
end

class TestMailer < ActionMailer::Base
def test_email; end
def email_with_args(arg1, arg2); end
Expand Down Expand Up @@ -413,6 +419,12 @@ def self.name; "NonMailerJob"; end
)
end

it "passes when given a global id serialised argument" do
expect {
UnifiedMailer.with(inquiry: GlobalIDArgument.new).test_email.deliver_later
}.to have_enqueued_email(UnifiedMailer, :test_email)
end

it "passes when using a mailer with `delivery_job` set to a sub class of `ActionMailer::DeliveryJob`" do
expect {
UnifiedMailerWithDeliveryJobSubClass.test_email.deliver_later
Expand Down

0 comments on commit 6f029a8

Please sign in to comment.