-
-
Notifications
You must be signed in to change notification settings - Fork 909
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
Scope parameters according to Rails version #989
Conversation
@@ -502,7 +502,7 @@ def params_with_conditional_require(params, *filters) | |||
|
|||
matcher.matches?(controller) | |||
|
|||
expect(context).to have_received(:patch).with(:update, {}) | |||
expect(context).to have_received(:patch).with(:update, expected_params) |
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.
Line is too long. [81/80]
lib/shoulda/matchers/rails_shim.rb
Outdated
else | ||
column.default | ||
simply_generate_validation_message(attribute, type, model_name, options) |
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.
Line is too long. [82/80]
lib/shoulda/matchers/rails_shim.rb
Outdated
::ActiveRecord::VERSION::MAJOR | ||
end | ||
|
||
def self.generate_validation_message(record, attribute, type, model_name, options) |
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.
Line is too long. [88/80]
@@ -502,7 +502,8 @@ def params_with_conditional_require(params, *filters) | |||
|
|||
matcher.matches?(controller) | |||
|
|||
expect(context).to have_received(:patch).with(:update, {}) | |||
expect(context) | |||
.to have_received(:patch).with(:update, expected_params) |
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.
Place the . on the previous line, together with the method call receiver.
lib/shoulda/matchers/rails_shim.rb
Outdated
:"errors.messages.#{type}" | ||
] | ||
primary_translation_key = :"activerecord.errors.models.#{model_name}.attributes.#{attribute}.#{type}" | ||
translate_options = { default: default_translation_keys }.merge(options) |
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.
Line is too long. [82/80]
lib/shoulda/matchers/rails_shim.rb
Outdated
:"errors.attributes.#{attribute}.#{type}", | ||
:"errors.messages.#{type}" | ||
] | ||
primary_translation_key = :"activerecord.errors.models.#{model_name}.attributes.#{attribute}.#{type}" |
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.
Line is too long. [111/80]
lib/shoulda/matchers/rails_shim.rb
Outdated
:"activerecord.errors.models.#{model_name}.#{type}", | ||
:"activerecord.errors.messages.#{type}", | ||
:"errors.attributes.#{attribute}.#{type}", | ||
:"errors.messages.#{type}" |
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.
Put a comma after the last item of a multiline array.
lib/shoulda/matchers/rails_shim.rb
Outdated
].join(".").to_sym | ||
|
||
translate_options = { | ||
default: default_translation_keys |
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.
Put a comma after the last item of a multiline hash.
lib/shoulda/matchers/rails_shim.rb
Outdated
"attributes", | ||
attribute, | ||
type, | ||
].join(".").to_sym |
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.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
lib/shoulda/matchers/rails_shim.rb
Outdated
primary_translation_key = [ | ||
"activerecord.errors.models", | ||
model_name, | ||
"attributes", |
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.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
lib/shoulda/matchers/rails_shim.rb
Outdated
Gem::Requirement.new('>= 4.1').satisfied_by?(action_pack_version) | ||
end | ||
primary_translation_key = [ | ||
"activerecord.errors.models", |
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.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
59a4310
to
aa32915
Compare
* Satisfy Rubocop * Alphabetize methods * Use `class << self` instead of `self.` so that we can privatize one of the methods
aa32915
to
9cf2820
Compare
lib/shoulda/matchers/rails_shim.rb
Outdated
end | ||
|
||
def self.action_pack_version | ||
Gem::Version.new(::ActionPack::VERSION::STRING) | ||
def self.make_controller_request(context, verb, action, request_params) |
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.
Method Shoulda::Matchers::RailsShim.make_controller_request is defined at both lib/shoulda/matchers/rails_shim.rb:48 and lib/shoulda/matchers/rails_shim.rb:131.
lib/shoulda/matchers/rails_shim.rb
Outdated
|
||
def self.action_pack_gte_4_1? | ||
Gem::Requirement.new('>= 4.1').satisfied_by?(action_pack_version) | ||
def simply_generate_validation_message( |
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.
Method has too many lines. [18/10]
else | ||
connection.tables | ||
serialized_columns.inject({}) do |hash, column| | ||
hash[column.name.to_s] = model.type_for_attribute(column.name).coder |
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.
Line is too long. [82/80]
translate_options = { default: default_translation_keys }.merge(options) | ||
I18n.translate(primary_translation_key, translate_options) | ||
end | ||
def serialized_attributes_for(model) |
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.
Method has too many lines. [14/10]
lib/shoulda/matchers/rails_shim.rb
Outdated
::ActiveRecord::VERSION::MAJOR | ||
end | ||
|
||
def generate_validation_message( |
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.
Method has too many lines. [17/10]
9cf2820
to
ca761db
Compare
|
||
private | ||
|
||
def simply_generate_validation_message( |
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.
Method has too many lines. [18/10]
|
||
private | ||
|
||
def simply_generate_validation_message( |
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.
Method has too many lines. [18/10]
Hey Murtaza -- thanks so much for this PR! I know it took a loooong time but your help is appreciated. 🌟 |
No worries, I appreciate that maintaining OS projects can be time consuming. Thanks for getting around to accepting this! 👍 |
Rails 5 has deprecated the keywords arguments for #permit. This patch scopes the request params according to the version of Rails.
This patch:
rails5
branch.Thank you (again) to @freesteph for helpin' out!