Skip to content

Improve mailer argument deserialisation for 6.1 on Ruby 3.1 #2566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 25, 2022

Conversation

JonRowe
Copy link
Member

@JonRowe JonRowe commented Jan 25, 2022

@pirj this is a simpler version of the changes required to fix mailers solely on Ruby 3.1 for Rails 6.1

The problem was not the different mailers but simply that Rails changed (only on 6.1) how it deserialized arguments, this logic restores that original implementation for our matcher and is the change I want to ship in the next 5.0 and 5.1 releases.

Arguably this could be in the jobs matcher and I'm surprised our specs pass as is for the jobs matcher, but its probably because that has less explicit requirements around deserialising.

I'm going to merge this to 5-1-maintenance and cherry pick to 5-0-maintenance on green, so you don't have to worry about that.

def ruby_3_1?
RUBY_VERSION >= "3.1"
end

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want this it should be in RSpec Support, its a later improvement that could be made once 3.11 is released.

}.to have_enqueued_mail(UnifiedMailer, :email_with_args).with({'foo' => 'bar'}, 1, 2)
}.to have_enqueued_mail(UnifiedMailer, :email_with_args).with(
a_hash_including(params: {'foo' => 'bar'}, args: [1, 2])
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just unpicks the changes to the behaviour

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if both:

have_enqueued_mail(UnifiedMailer, :email_with_args).with(
          a_hash_including(params: {'foo' => 'bar'}, args: [1, 2])
        )

and

have_enqueued_mail(UnifiedMailer, :email_with_args).with({'foo' => 'bar'}, 1, 2)

would match.
I was believing that the change from #2516 made both match, but it's not confirmed in specs.

@JonRowe JonRowe force-pushed the ruby-31-mailer-fixes branch 6 times, most recently from 84f4b30 to b427c6e Compare January 25, 2022 13:25
@JonRowe JonRowe force-pushed the ruby-31-mailer-fixes branch from b427c6e to d9dc770 Compare January 25, 2022 13:31
@JonRowe JonRowe merged commit 895f14e into 5-1-maintenance Jan 25, 2022
@JonRowe JonRowe deleted the ruby-31-mailer-fixes branch January 25, 2022 14:07
JonRowe added a commit that referenced this pull request Jan 25, 2022
Improve mailer argument deserialisation for 6.1 on Ruby 3.1
JonRowe added a commit that referenced this pull request Jan 26, 2022
JonRowe added a commit that referenced this pull request Jan 26, 2022
@pirj
Copy link
Member

pirj commented Jan 26, 2022

I really like how you've structured the code here.
Do you want me to attempt to adjust how we handle this for 6.0 in #2554?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants