diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-23 15:09:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-23 15:09:20 +0300 |
commit | b7e512c8970dcce6feabc096885c7a1ea91e4694 (patch) | |
tree | 6efe91e491d584dba8a6d35b9bd19111adf4e519 /spec/rubocop/cop/migration | |
parent | 698ab7c4bba77ffc98c14360269167092b2ebe01 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop/cop/migration')
-rw-r--r-- | spec/rubocop/cop/migration/drop_table_spec.rb | 72 |
1 files changed, 61 insertions, 11 deletions
diff --git a/spec/rubocop/cop/migration/drop_table_spec.rb b/spec/rubocop/cop/migration/drop_table_spec.rb index 4fe7fc8c5a5..b24e350388c 100644 --- a/spec/rubocop/cop/migration/drop_table_spec.rb +++ b/spec/rubocop/cop/migration/drop_table_spec.rb @@ -17,20 +17,70 @@ describe RuboCop::Cop::Migration::DropTable do allow(cop).to receive(:in_deployment_migration?).and_return(true) end - it 'registers an offense' do - expect_offense(<<~PATTERN) - def change - drop_table :table - ^^^^^^^^^^ #{described_class::MSG} - - add_column(:users, :username, :text) + context 'with drop_table DSL method' do + context 'when in down method' do + it 'does not register an offense' do + expect_no_offenses(<<~PATTERN) + def down + drop_table :table + end + PATTERN + end + end - execute "DROP TABLE table" - ^^^^^^^ #{described_class::MSG} + context 'when in up method' do + it 'registers an offense' do + expect_offense(<<~PATTERN) + def up + drop_table :table + ^^^^^^^^^^ #{described_class::MSG} + end + PATTERN + end + end - execute "CREATE UNIQUE INDEX email_index ON users (email);" + context 'when in change method' do + it 'registers an offense' do + expect_offense(<<~PATTERN) + def change + drop_table :table + ^^^^^^^^^^ #{described_class::MSG} + end + PATTERN end - PATTERN + end + end + + context 'with DROP TABLE SQL literal' do + it 'does not register an offense' do + expect_no_offenses(<<~PATTERN) + def down + execute "DROP TABLE table" + end + PATTERN + end + end + + context 'when in up method' do + it 'registers an offense' do + expect_offense(<<~PATTERN) + def up + execute "DROP TABLE table" + ^^^^^^^ #{described_class::MSG} + end + PATTERN + end + end + + context 'when in change method' do + it 'registers an offense' do + expect_offense(<<~PATTERN) + def change + execute "DROP TABLE table" + ^^^^^^^ #{described_class::MSG} + end + PATTERN + end end end |