-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Deprecate string options in URL helpers #17743
Deprecate string options in URL helpers #17743
Conversation
I think this would need a changelog |
If you want to credit someone else, put both names in the changelog, and at the bottom of the commit message put |
@@ -293,6 +293,19 @@ def handle_positional_args(controller_options, inner_options, args, result, path | |||
|
|||
result.merge!(inner_options) | |||
end | |||
|
|||
DEPRECATED_STRING_OPTIONS = %w[controller action].freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a good idea.
eedc183
to
3da29bd
Compare
Thanks for the feedback! Made the suggested changes and added a changelog entry. |
❤️ |
ActiveSupport::Deprecation.warn(msg) | ||
DEPRECATED_STRING_OPTIONS.each do |option| | ||
value = options.delete(option) | ||
options[option.to_sym] ||= value if value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a pretty complex logic here without test. For example, why were are using ||=
? Why we need to check if value
is present?
I'd add tests for these cases to make sure we don't have regressions on this code.
This looks good to me |
DEPRECATED_STRING_OPTIONS = Set.new(%w[controller action]) | ||
|
||
def deprecate_string_options(options = {}) | ||
if options && options.each_key.any? { |k| DEPRECATED_STRING_OPTIONS.include?(k) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be better to write
if options && (deprecated_string_options = options & DEPRECATED_STRING_OPTIONS)
and we use the deprecated_string_options
variable to print the correct message and to iterate on the each
loop.
This way to deleting an option that doesn't existe there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would need to be on the keys specifically. I think that'd be more readable on two lines, as well. :)
3da29bd
to
8b59aa2
Compare
@@ -293,6 +293,22 @@ def handle_positional_args(controller_options, inner_options, args, result, path | |||
|
|||
result.merge!(inner_options) | |||
end | |||
|
|||
DEPRECATED_STRING_OPTIONS = Set.new(%w[controller action]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it need to be a set now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. I'm about to merge, will fix as I merge.
8b59aa2
to
4d84922
Compare
Fixes rails#16958 [Byron Bischoff & Melanie Gilman]
4d84922
to
ce28e89
Compare
Gah... We tried to update the changelog format at the same time. This was merged. |
Add release note for #17743 [ci skip]
Something is wrong with this: admin_dashboard_path(params) Where
|
Fixes #16958
I pretty much implemented @bronzle's fix in the issue comments, so he should have credit too.