Skip to content

Commit d8d4489

Browse files
authored
Merge pull request #606 from TonyArra/reversible-migration-remove-reference
[Fix #604] Remove `remove_reference` checks from `Rails/ReversibleMigration`
2 parents d0e6bcf + bf3d379 commit d8d4489

File tree

4 files changed

+3
-29
lines changed

4 files changed

+3
-29
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,3 +503,4 @@
503503
[@vitormd]: https://github.com/vitormd
504504
[@mattmccormick]: https://github.com/mattmccormick
505505
[@leoarnold]: https://github.com/leoarnold
506+
[@TonyArra]: https://github.com/TonyArra
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#604](https://github.com/rubocop/rubocop-rails/issues/604): Remove `remove_reference` and `remove_belongs_to` methods from `Rails/ReversibleMigration` cop offenses. ([@TonyArra][])

lib/rubocop/cop/rails/reversible_migration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class ReversibleMigration < Base
179179
MSG = '%<action>s is not reversible.'
180180

181181
def_node_matcher :irreversible_schema_statement_call, <<~PATTERN
182-
(send nil? ${:change_column :execute :remove_belongs_to :remove_reference} ...)
182+
(send nil? ${:change_column :execute} ...)
183183
PATTERN
184184

185185
def_node_matcher :drop_table_call, <<~PATTERN

spec/rubocop/cop/rails/reversible_migration_spec.rb

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,6 @@ def change
171171
RUBY
172172
end
173173

174-
context 'remove_belongs_to' do
175-
it_behaves_like 'accepts', 'up_only', <<~RUBY
176-
up_only { remove_belongs_to(:products, :user, index: false) }
177-
RUBY
178-
179-
it_behaves_like 'offense', 'remove_belongs_to', <<~RUBY
180-
remove_belongs_to(:products, :user, index: false)
181-
RUBY
182-
183-
it_behaves_like 'offense', 'remove_belongs_to', <<~RUBY
184-
remove_belongs_to(:products, :supplier, polymorphic: true)
185-
RUBY
186-
end
187-
188174
context 'remove_column' do
189175
it_behaves_like 'accepts', 'remove_column(with type)', <<~RUBY
190176
remove_column(:suppliers, :qualification, :string)
@@ -213,20 +199,6 @@ def change
213199
RUBY
214200
end
215201

216-
context 'remove_reference' do
217-
it_behaves_like 'accepts', 'up_only', <<~RUBY
218-
up_only { remove_reference(:products, :user, index: false) }
219-
RUBY
220-
221-
it_behaves_like 'offense', 'remove_reference', <<~RUBY
222-
remove_reference(:products, :user, index: false)
223-
RUBY
224-
225-
it_behaves_like 'offense', 'remove_reference', <<~RUBY
226-
remove_reference(:products, :supplier, polymorphic: true)
227-
RUBY
228-
end
229-
230202
context 'change_table' do
231203
it_behaves_like 'accepts', 'change_table(with reversible calls)', <<~RUBY
232204
change_table :users do |t|

0 commit comments

Comments
 (0)