summaryrefslogtreecommitdiff
path: root/spec/rubocop/cop/migration/with_lock_retries_disallowed_method_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubocop/cop/migration/with_lock_retries_disallowed_method_spec.rb')
-rw-r--r--spec/rubocop/cop/migration/with_lock_retries_disallowed_method_spec.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/rubocop/cop/migration/with_lock_retries_disallowed_method_spec.rb b/spec/rubocop/cop/migration/with_lock_retries_disallowed_method_spec.rb
index 11e4d784617..607daf0c9f0 100644
--- a/spec/rubocop/cop/migration/with_lock_retries_disallowed_method_spec.rb
+++ b/spec/rubocop/cop/migration/with_lock_retries_disallowed_method_spec.rb
@@ -53,6 +53,22 @@ RSpec.describe RuboCop::Cop::Migration::WithLockRetriesDisallowedMethod, type: :
expect(cop.offenses.size).to eq(0)
end
+
+ describe 'for `add_foreign_key`' do
+ it 'registers an offense when more than two FKs are added' do
+ message = described_class::MSG_ONLY_ONE_FK_ALLOWED
+
+ expect_offense <<~RUBY
+ with_lock_retries do
+ add_foreign_key :imports, :projects, column: :project_id, on_delete: :cascade
+ ^^^^^^^^^^^^^^^ #{message}
+ add_column :projects, :name, :text
+ add_foreign_key :imports, :users, column: :user_id, on_delete: :cascade
+ ^^^^^^^^^^^^^^^ #{message}
+ end
+ RUBY
+ end
+ end
end
context 'outside of migration' do