Skip to content
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

Fix formatting ActionController::Parameters #29

Merged
merged 7 commits into from
May 18, 2020
Merged

Conversation

HarlemSquirrel
Copy link
Member

Add an extra check for unpermitted Rails paramters
that will report they they respond to :to_hash
but raise an error.

Fixes #17

Add an extra check for unpermitted Rails paramters
that will report they they respond to :to_hash
but raise an error.

Fixes #17
@HarlemSquirrel HarlemSquirrel requested a review from paddor May 4, 2020 14:35
Copy link
Contributor

@paddor paddor left a comment

Choose a reason for hiding this comment

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

@HarlemSquirrel almost ready to merge. Just wondering about that regexp 😅

@@ -259,7 +259,7 @@ class SubUser < User {
expect(out).to match(
/\s*first\(\*args,\s+&block\)\s+#<Class:ActiveRecord::Base> \(ActiveRecord::Querying\)/
)
elsif RUBY_VERSION >= '2.4.4'
elsif RUBY_VERSION =~ /2\.[4-6]\.([4-9]|[1-9][0-9])/
Copy link
Contributor

Choose a reason for hiding this comment

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

Why exactly that regexp? Why not =~ /2\.[4-6]\.\d+/ or simply >= '2.4.0' since the branch for 2.7 is above? Or >= '2.4.0' && < '2.7.0'?

Copy link
Member Author

Choose a reason for hiding this comment

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

So we need to find version greater than or equal to 2.4.4 and now that 2.4.10 is out, the string comparison fails with that version.

'2.4.3' >= '2.4.4'
# => false
'2.4.4' >= '2.4.4'
# => true
'2.4.10' >= '2.4.4'
# => false

'2.4.3' =~ /2\.[4-6]\.([4-9]|[1-9][0-9])/
# => nil
'2.4.4' =~ /2\.[4-6]\.([4-9]|[1-9][0-9])/
# => 0
'2.4.10' =~ /2\.[4-6]\.([4-9]|[1-9][0-9])/
# => 0

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. But the restrictions then also apply to Ruby 2.5 and 2.6.

How about: /^2\.4\.([4-9]|[1-9][0-9])|^2\.[56]\./

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

@HarlemSquirrel
Copy link
Member Author

OK, I had to run bundle exec appraisal rails-6.0 rspec to reproduce this new failure locally. It appears that with Ruby 2.7 and ActiveRecord 6.0.3 things have changed a bit. I have to see what's the best approach to handle this.

@HarlemSquirrel HarlemSquirrel requested a review from paddor May 18, 2020 00:46
@paddor paddor merged commit c345744 into master May 18, 2020
@HarlemSquirrel HarlemSquirrel deleted the rails-unpermitted-params branch May 19, 2020 00:24
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