Skip to content

Commit

Permalink
[Fix rubocop#604] Remove remove_reference checks from `Rails/Revers…
Browse files Browse the repository at this point in the history
…ibleMigration`

This reverts commit 798b39e.

Remove `belongs_to` and `remove_reference` checks from `Rails/ReversibleMigration`.
  • Loading branch information
TonyArra committed Dec 28, 2021
1 parent 1e9c257 commit e713820
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 29 deletions.
1 change: 1 addition & 0 deletions changelog/new_remove_remove_reference_checks_from.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#604](https://github.com/rubocop/rubocop-rails/issues/604): Remove `remove_reference` checks from `Rails/ReversibleMigration`. ([@TonyArra][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/reversible_migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class ReversibleMigration < Base
MSG = '%<action>s is not reversible.'

def_node_matcher :irreversible_schema_statement_call, <<~PATTERN
(send nil? ${:change_column :execute :remove_belongs_to :remove_reference} ...)
(send nil? ${:change_column :execute} ...)
PATTERN

def_node_matcher :drop_table_call, <<~PATTERN
Expand Down
28 changes: 0 additions & 28 deletions spec/rubocop/cop/rails/reversible_migration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,6 @@ def change
RUBY
end

context 'remove_belongs_to' do
it_behaves_like 'accepts', 'up_only', <<~RUBY
up_only { remove_belongs_to(:products, :user, index: false) }
RUBY

it_behaves_like 'offense', 'remove_belongs_to', <<~RUBY
remove_belongs_to(:products, :user, index: false)
RUBY

it_behaves_like 'offense', 'remove_belongs_to', <<~RUBY
remove_belongs_to(:products, :supplier, polymorphic: true)
RUBY
end

context 'remove_column' do
it_behaves_like 'accepts', 'remove_column(with type)', <<~RUBY
remove_column(:suppliers, :qualification, :string)
Expand Down Expand Up @@ -213,20 +199,6 @@ def change
RUBY
end

context 'remove_reference' do
it_behaves_like 'accepts', 'up_only', <<~RUBY
up_only { remove_reference(:products, :user, index: false) }
RUBY

it_behaves_like 'offense', 'remove_reference', <<~RUBY
remove_reference(:products, :user, index: false)
RUBY

it_behaves_like 'offense', 'remove_reference', <<~RUBY
remove_reference(:products, :supplier, polymorphic: true)
RUBY
end

context 'change_table' do
it_behaves_like 'accepts', 'change_table(with reversible calls)', <<~RUBY
change_table :users do |t|
Expand Down

0 comments on commit e713820

Please sign in to comment.