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

Scope parameters according to Rails version #989

Merged
merged 2 commits into from
Sep 17, 2017

Conversation

mygulamali
Copy link
Contributor

Rails 5 has deprecated the keywords arguments for #permit. This patch scopes the request params according to the version of Rails.

This patch:

Thank you (again) to @freesteph for helpin' out!

@@ -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)

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]

else
column.default
simply_generate_validation_message(attribute, type, model_name, options)

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]

::ActiveRecord::VERSION::MAJOR
end

def self.generate_validation_message(record, attribute, type, model_name, options)

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)

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.

:"errors.messages.#{type}"
]
primary_translation_key = :"activerecord.errors.models.#{model_name}.attributes.#{attribute}.#{type}"
translate_options = { default: default_translation_keys }.merge(options)

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]

:"errors.attributes.#{attribute}.#{type}",
:"errors.messages.#{type}"
]
primary_translation_key = :"activerecord.errors.models.#{model_name}.attributes.#{attribute}.#{type}"

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]

:"activerecord.errors.models.#{model_name}.#{type}",
:"activerecord.errors.messages.#{type}",
:"errors.attributes.#{attribute}.#{type}",
:"errors.messages.#{type}"

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.

].join(".").to_sym

translate_options = {
default: default_translation_keys

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.

"attributes",
attribute,
type,
].join(".").to_sym

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.

primary_translation_key = [
"activerecord.errors.models",
model_name,
"attributes",

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.

Gem::Requirement.new('>= 4.1').satisfied_by?(action_pack_version)
end
primary_translation_key = [
"activerecord.errors.models",

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.

@guialbuk guialbuk changed the base branch from rails5 to rails-5 April 25, 2017 20:34
@mcmire mcmire force-pushed the mygulamali-fix-keyword-params branch 2 times, most recently from 59a4310 to aa32915 Compare September 17, 2017 19:52
* Satisfy Rubocop
* Alphabetize methods
* Use `class << self` instead of `self.` so that we can privatize one of
  the methods
@mcmire mcmire force-pushed the mygulamali-fix-keyword-params branch from aa32915 to 9cf2820 Compare September 17, 2017 21:31
end

def self.action_pack_version
Gem::Version.new(::ActionPack::VERSION::STRING)
def self.make_controller_request(context, verb, action, request_params)

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.


def self.action_pack_gte_4_1?
Gem::Requirement.new('>= 4.1').satisfied_by?(action_pack_version)
def simply_generate_validation_message(

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

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)

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]

::ActiveRecord::VERSION::MAJOR
end

def generate_validation_message(

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]

@mcmire mcmire force-pushed the mygulamali-fix-keyword-params branch from 9cf2820 to ca761db Compare September 17, 2017 21:35

private

def simply_generate_validation_message(

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(

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]

@mcmire mcmire merged commit ca761db into rails-5 Sep 17, 2017
@mcmire mcmire deleted the mygulamali-fix-keyword-params branch September 17, 2017 21:58
@mcmire
Copy link
Collaborator

mcmire commented Sep 17, 2017

Hey Murtaza -- thanks so much for this PR! I know it took a loooong time but your help is appreciated. 🌟

@mygulamali
Copy link
Contributor Author

No worries, I appreciate that maintaining OS projects can be time consuming. Thanks for getting around to accepting this! 👍

@mcmire mcmire added this to the v4.0 milestone Sep 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants