You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
git clone https://github.com/rubocop-hq/rubocop-rails.git && cd rubocop-rails && bundle install
Save the following patch as patch.diff
diff --git a/spec/rubocop/cop/rails/has_many_or_has_one_dependent_spec.rb b/spec/rubocop/cop/rails/has_many_or_has_one_dependent_spec.rb
index 2d9ab5e60..a99b4a9a9 100644
--- a/spec/rubocop/cop/rails/has_many_or_has_one_dependent_spec.rb+++ b/spec/rubocop/cop/rails/has_many_or_has_one_dependent_spec.rb@@ -132,6 +132,19 @@ RSpec.describe RuboCop::Cop::Rails::HasManyOrHasOneDependent do
RUBY
end
+ it "doesn't register an offense for `with_options dependent: :destroy` and for using association extension" do+ expect_no_offenses(<<~RUBY)+ class Person < ApplicationRecord+ with_options dependent: :destroy do+ has_many :foo do+ def bar+ end+ end+ end+ end+ RUBY+ end+
context 'Multiple associations' do
it "doesn't register an offense for " \
'`with_options dependent: :destroy`' do
Rails/HasManyOrHasOneDependent
should allow combination of association extension andwith_options
.As for association extensions, please see the official document.
Expected behavior
The following code does not offense
Rails/HasManyOrHasOneDependent
cop rule since it actually givesdependent
option.Actual behavior
rubocop-rails
treats the code as offensed.Steps to reproduce the problem
git clone https://github.com/rubocop-hq/rubocop-rails.git && cd rubocop-rails && bundle install
patch.diff
git apply patch.diff
bundle exec rspec spec/rubocop/cop/rails/has_many_or_has_one_dependent_spec.rb:135
RuboCop version
The text was updated successfully, but these errors were encountered: