diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-27 21:09:17 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-27 21:09:17 +0000 |
commit | c77fda905a8619b756163c10a75171dc9cfe7084 (patch) | |
tree | ffa93b37bfe4b99ba0b8584c7a0bd1a4cd19772a /spec/rubocop/cop/migration | |
parent | e0fa0638a422c3e20d4423c9bb69d79afc9c7d3d (diff) | |
download | gitlab-ce-c77fda905a8619b756163c10a75171dc9cfe7084.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop/cop/migration')
-rw-r--r-- | spec/rubocop/cop/migration/add_column_with_default_spec.rb | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/spec/rubocop/cop/migration/add_column_with_default_spec.rb b/spec/rubocop/cop/migration/add_column_with_default_spec.rb index f3518f2f058..a8cf965a3ef 100644 --- a/spec/rubocop/cop/migration/add_column_with_default_spec.rb +++ b/spec/rubocop/cop/migration/add_column_with_default_spec.rb @@ -16,7 +16,7 @@ describe RuboCop::Cop::Migration::AddColumnWithDefault do it 'does not register any offenses' do expect_no_offenses(<<~RUBY) def up - add_column_with_default(:ci_build_needs, :artifacts, :boolean, default: true, allow_null: false) + add_column_with_default(:merge_request_diff_files, :artifacts, :boolean, default: true, allow_null: false) end RUBY end @@ -29,38 +29,42 @@ describe RuboCop::Cop::Migration::AddColumnWithDefault do let(:offense) { '`add_column_with_default` without `allow_null: true` may cause prolonged lock situations and downtime, see https://gitlab.com/gitlab-org/gitlab/issues/38060' } - it 'registers an offense when specifying allow_null: false' do - expect_offense(<<~RUBY) - def up - add_column_with_default(:ci_build_needs, :artifacts, :boolean, default: true, allow_null: false) - ^^^^^^^^^^^^^^^^^^^^^^^ #{offense} - end - RUBY - end + context 'for blacklisted table' do + it 'registers an offense when specifying allow_null: false' do + expect_offense(<<~RUBY) + def up + add_column_with_default(:merge_request_diff_files, :artifacts, :boolean, default: true, allow_null: false) + ^^^^^^^^^^^^^^^^^^^^^^^ #{offense} + end + RUBY + end - it 'registers no offense when specifying allow_null: true' do - expect_no_offenses(<<~RUBY) - def up - add_column_with_default(:ci_build_needs, :artifacts, :boolean, default: true, allow_null: true) - end - RUBY - end + it 'registers no offense when specifying allow_null: true' do + expect_no_offenses(<<~RUBY) + def up + add_column_with_default(:merge_request_diff_files, :artifacts, :boolean, default: true, allow_null: true) + end + RUBY + end - it 'registers an offense when allow_null is not specified' do - expect_offense(<<~RUBY) - def up - add_column_with_default(:ci_build_needs, :artifacts, :boolean, default: true) - ^^^^^^^^^^^^^^^^^^^^^^^ #{offense} - end - RUBY + it 'registers an offense when allow_null is not specified' do + expect_offense(<<~RUBY) + def up + add_column_with_default(:merge_request_diff_files, :artifacts, :boolean, default: true) + ^^^^^^^^^^^^^^^^^^^^^^^ #{offense} + end + RUBY + end end - it 'registers no offense for application_settings (whitelisted table)' do - expect_no_offenses(<<~RUBY) - def up - add_column_with_default(:application_settings, :another_column, :boolean, default: true, allow_null: false) - end - RUBY + context 'for tables not on the blacklist' do + it 'registers no offense for application_settings (not on blacklist)' do + expect_no_offenses(<<~RUBY) + def up + add_column_with_default(:application_settings, :another_column, :boolean, default: true, allow_null: false) + end + RUBY + end end end end |