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/HasManyOrHasOneDependent false positive #5234

Closed
6temes opened this issue Dec 13, 2017 · 1 comment · Fixed by #5235
Closed

Rails/HasManyOrHasOneDependent false positive #5234

6temes opened this issue Dec 13, 2017 · 1 comment · Fixed by #5235

Comments

@6temes
Copy link

6temes commented Dec 13, 2017

Expected behavior

With the following code snippet, Rubocop should not trigger any error:

class MyModel
  with_options inverse_of: :my_model, dependent: :restrict_with_exception do
    has_many :some_associations
    has_many :a_other_associations, class_name: 'A::OtherAssociation'
    has_many :b_other_associations, class_name: 'B::OtherAssociation'
  end
end

Actual behavior

Rubocop triggers "Rails/HasManyOrHasOneDependent" for the two has_many associations that have the class_name argument.

Steps to reproduce the problem

Copypaste the example code above.

RuboCop version

$ rubocop -V
0.52.0
@koic
Copy link
Member

koic commented Dec 13, 2017

I confirmed this issue reproduce and opened a PR. Thanks!
#5235

koic added a commit to koic/rubocop that referenced this issue Dec 15, 2017
…endent`

Fixes rubocop#5234.

Since there was no test case using `class_name` option in `with_options`
block, this PR added it as a reproduction test and fixed it.
bbatsov pushed a commit that referenced this issue Dec 15, 2017
Fixes #5234.

Since there was no test case using `class_name` option in `with_options`
block, this PR added it as a reproduction test and fixed it.
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