Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-15 18:08:04 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-15 18:08:04 +0300
commitc4c1fc5fe7c756fc6f8f79eb1624b1bbe4fe2d69 (patch)
tree8c95e39fc4956cdd9178c46ea85cbeeeac3bc360 /spec/rubocop
parent927df95cc4453bdacbc59960df32008b02c4e28a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop')
-rw-r--r--spec/rubocop/cop/migration/add_column_with_default_spec.rb45
-rw-r--r--spec/rubocop/cop/migration/add_columns_to_wide_tables_spec.rb4
-rw-r--r--spec/rubocop/cop/migration/reversible_add_column_with_default_spec.rb43
3 files changed, 10 insertions, 82 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 a8cf965a3ef..5d4fc59fb95 100644
--- a/spec/rubocop/cop/migration/add_column_with_default_spec.rb
+++ b/spec/rubocop/cop/migration/add_column_with_default_spec.rb
@@ -27,44 +27,15 @@ describe RuboCop::Cop::Migration::AddColumnWithDefault do
allow(cop).to receive(:in_migration?).and_return(true)
end
- 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' }
+ let(:offense) { '`add_column_with_default` is deprecated, use `add_column` instead' }
- 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(: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(:merge_request_diff_files, :artifacts, :boolean, default: true)
- ^^^^^^^^^^^^^^^^^^^^^^^ #{offense}
- end
- RUBY
- end
- end
-
- 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
+ it 'registers an offense ' 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
end
end
diff --git a/spec/rubocop/cop/migration/add_columns_to_wide_tables_spec.rb b/spec/rubocop/cop/migration/add_columns_to_wide_tables_spec.rb
index f0c64740e63..5b179168eab 100644
--- a/spec/rubocop/cop/migration/add_columns_to_wide_tables_spec.rb
+++ b/spec/rubocop/cop/migration/add_columns_to_wide_tables_spec.rb
@@ -42,8 +42,8 @@ describe RuboCop::Cop::Migration::AddColumnsToWideTables do
expect_offense(<<~RUBY)
def up
- add_column_with_default(:users, :another_column, :boolean, default: false)
- ^^^^^^^^^^^^^^^^^^^^^^^ #{offense}
+ add_column(:users, :another_column, :boolean, default: false)
+ ^^^^^^^^^^ #{offense}
end
RUBY
end
diff --git a/spec/rubocop/cop/migration/reversible_add_column_with_default_spec.rb b/spec/rubocop/cop/migration/reversible_add_column_with_default_spec.rb
deleted file mode 100644
index b3c5b855004..00000000000
--- a/spec/rubocop/cop/migration/reversible_add_column_with_default_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-require 'rubocop'
-require 'rubocop/rspec/support'
-
-require_relative '../../../../rubocop/cop/migration/reversible_add_column_with_default'
-
-describe RuboCop::Cop::Migration::ReversibleAddColumnWithDefault do
- include CopHelper
-
- subject(:cop) { described_class.new }
-
- context 'in migration' do
- before do
- allow(cop).to receive(:in_migration?).and_return(true)
- end
-
- it 'registers an offense when add_column_with_default is used inside a change method' do
- inspect_source('def change; add_column_with_default :table, :column, default: false; end')
-
- aggregate_failures do
- expect(cop.offenses.size).to eq(1)
- expect(cop.offenses.map(&:line)).to eq([1])
- end
- end
-
- it 'registers no offense when add_column_with_default is used inside an up method' do
- inspect_source('def up; add_column_with_default :table, :column, default: false; end')
-
- expect(cop.offenses.size).to eq(0)
- end
- end
-
- context 'outside of migration' do
- it 'registers no offense' do
- inspect_source('def change; add_column_with_default :table, :column, default: false; end')
-
- expect(cop.offenses.size).to eq(0)
- end
- end
-end