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

Rails/SkipsModelValidations is inconsistence with touch #12

Closed
Ana06 opened this issue Sep 18, 2018 · 1 comment · Fixed by #232
Closed

Rails/SkipsModelValidations is inconsistence with touch #12

Ana06 opened this issue Sep 18, 2018 · 1 comment · Fixed by #232

Comments

@Ana06
Copy link

Ana06 commented Sep 18, 2018

Rails/SkipsModelValidations cop doesn't complain about the following relation:

belongs_to :user, touch: true

but it does complain in its test (Avoid using touch because it skips validations.):

it { should belong_to(:user).touch(true) }

Expected behavior

Complain in both cases or in any of them. I would say that it should also complain in the relation.

RuboCop version

0.47.1

Originally opened at rubocop/rubocop#4098

@derikson
Copy link

I think it's confusing the shoulda-matcher #touch method with ActiveRecord::Persistance#touch

eugeneius added a commit to eugeneius/rubocop-rails that referenced this issue Apr 11, 2020
The `Rails/SkipsModelValidations` cop currently incorrectly registers an
offense for the `touch` method from Shoulda Matchers' associations DSL:

    it { is_expected.to belong_to(:user).touch(true) }

Active Record's `touch` method accepts attribute names, so we can treat
`touch` calls that pass boolean literal arguments as false positives.
@koic koic closed this as completed in #232 Apr 12, 2020
koic added a commit that referenced this issue Apr 12, 2020
[Fix #12] Allow passing boolean literals to touch
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 a pull request may close this issue.

2 participants