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 does not handle with_options blocks properly #4909

Closed
yskkin opened this issue Oct 23, 2017 · 0 comments · Fixed by #4933
Closed

Rails/HasManyOrHasOneDependent does not handle with_options blocks properly #4909

yskkin opened this issue Oct 23, 2017 · 0 comments · Fixed by #4933
Labels

Comments

@yskkin
Copy link

yskkin commented Oct 23, 2017

Expected behavior

There are no offenses when validating a model file with has several has_many/has_one in with_options block.

Actual behavior

If there are two or more has_many/has_one in with_options block, offenses are generated for each association.

Steps to reproduce the problem

Modify a test in spec/rubocop/cop/rails/has_many_or_has_one_dependent_spec.rb as follows.

      it "doesn't register an offense for `with_options dependent: :destroy`" do
        expect_no_offenses(<<-RUBY.strip_indent)
          class Person
            with_options dependent: :destroy do
              has_many :foo
              has_many :bar
            end
          end
        RUBY
      end

RuboCop version

$ rubocop -V
0.51.0 (using Parser 2.4.0.0, running on ruby 2.4.0 x86_64-darwin16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants