Skip to content

Make behavior arguments optional #44

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
Apr 24, 2022
Merged

Make behavior arguments optional #44

merged 1 commit into from
Apr 24, 2022

Conversation

arielj
Copy link

@arielj arielj commented Apr 18, 2022

Description:

This PR fixes #23 by making the last 2 arguments for the custom behavior optional.

Before Rails 5.2, the behavior only supported 2 arguments and ActiveSupport would call the behavior with only 2 arguments (then the error given 2, expected 4). By making the unused arguments optional the code works fine in older Rails versions.

Behaviors in Rails < 5.2: https://github.com/rails/rails/blob/5-1-stable/activesupport/lib/active_support/deprecation/behaviors.rb#L12
Behaviors since Rails >= 5.2: https://github.com/rails/rails/blob/5-2-stable/activesupport/lib/active_support/deprecation/behaviors.rb#L14

I tested this by creating a Rails 5.1.7 project, adding next_rails to track deprecations and manually added a deprecation warning both before and after this change and I can confirm this fixes the issue.

I will abide by the code of conduct.

@arielj arielj requested a review from a team as a code owner April 18, 2022 18:07
@arielj arielj requested review from bronzdoc and kindoflew and removed request for a team April 18, 2022 18:08
Copy link

@lubc lubc left a comment

Choose a reason for hiding this comment

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

@arielj Great finding! Thanks you!

@lubc lubc merged commit efa382b into main Apr 24, 2022
@lubc lubc deleted the fixes/behavior-arguments branch April 24, 2022 18:15
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.

DEPRECATION_TRACKER=save rspec spec raises ArgumentError
3 participants