diff options
Diffstat (limited to 'spec/rubocop/cop/migration')
31 files changed, 32 insertions, 78 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 3f47613280f..865f567db44 100644 --- a/spec/rubocop/cop/migration/add_column_with_default_spec.rb +++ b/spec/rubocop/cop/migration/add_column_with_default_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/add_column_with_default' RSpec.describe RuboCop::Cop::Migration::AddColumnWithDefault do 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 b78ec971245..7cc88946cf1 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 @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/add_columns_to_wide_tables' RSpec.describe RuboCop::Cop::Migration::AddColumnsToWideTables do diff --git a/spec/rubocop/cop/migration/add_concurrent_foreign_key_spec.rb b/spec/rubocop/cop/migration/add_concurrent_foreign_key_spec.rb index 572c0d414b3..aa39f5f1603 100644 --- a/spec/rubocop/cop/migration/add_concurrent_foreign_key_spec.rb +++ b/spec/rubocop/cop/migration/add_concurrent_foreign_key_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/add_concurrent_foreign_key' RSpec.describe RuboCop::Cop::Migration::AddConcurrentForeignKey do diff --git a/spec/rubocop/cop/migration/add_concurrent_index_spec.rb b/spec/rubocop/cop/migration/add_concurrent_index_spec.rb index 52b3a5769ff..185b64b0334 100644 --- a/spec/rubocop/cop/migration/add_concurrent_index_spec.rb +++ b/spec/rubocop/cop/migration/add_concurrent_index_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/add_concurrent_index' RSpec.describe RuboCop::Cop::Migration::AddConcurrentIndex do - subject(:cop) { described_class.new } - context 'when in migration' do before do allow(cop).to receive(:in_migration?).and_return(true) diff --git a/spec/rubocop/cop/migration/add_index_spec.rb b/spec/rubocop/cop/migration/add_index_spec.rb index 088bfe434f4..338dbf73a3a 100644 --- a/spec/rubocop/cop/migration/add_index_spec.rb +++ b/spec/rubocop/cop/migration/add_index_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/add_index' RSpec.describe RuboCop::Cop::Migration::AddIndex do - subject(:cop) { described_class.new } - context 'in migration' do before do allow(cop).to receive(:in_migration?).and_return(true) diff --git a/spec/rubocop/cop/migration/add_limit_to_text_columns_spec.rb b/spec/rubocop/cop/migration/add_limit_to_text_columns_spec.rb index f6bed0d74fb..85a86a27c48 100644 --- a/spec/rubocop/cop/migration/add_limit_to_text_columns_spec.rb +++ b/spec/rubocop/cop/migration/add_limit_to_text_columns_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/add_limit_to_text_columns' RSpec.describe RuboCop::Cop::Migration::AddLimitToTextColumns do - subject(:cop) { described_class.new } - context 'when in migration' do let(:msg) { 'Text columns should always have a limit set (255 is suggested)[...]' } diff --git a/spec/rubocop/cop/migration/add_reference_spec.rb b/spec/rubocop/cop/migration/add_reference_spec.rb index 9445780e9ed..bb3fe7068b4 100644 --- a/spec/rubocop/cop/migration/add_reference_spec.rb +++ b/spec/rubocop/cop/migration/add_reference_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/add_reference' RSpec.describe RuboCop::Cop::Migration::AddReference do diff --git a/spec/rubocop/cop/migration/add_timestamps_spec.rb b/spec/rubocop/cop/migration/add_timestamps_spec.rb index 2a11d46be6e..fcc2f4aa363 100644 --- a/spec/rubocop/cop/migration/add_timestamps_spec.rb +++ b/spec/rubocop/cop/migration/add_timestamps_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/add_timestamps' RSpec.describe RuboCop::Cop::Migration::AddTimestamps do - subject(:cop) { described_class.new } - let(:migration_with_add_timestamps) do %q( class Users < ActiveRecord::Migration[4.2] diff --git a/spec/rubocop/cop/migration/background_migration_base_class_spec.rb b/spec/rubocop/cop/migration/background_migration_base_class_spec.rb index 0a110418139..8cc85ac692c 100644 --- a/spec/rubocop/cop/migration/background_migration_base_class_spec.rb +++ b/spec/rubocop/cop/migration/background_migration_base_class_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/background_migration_base_class' RSpec.describe RuboCop::Cop::Migration::BackgroundMigrationBaseClass do - subject(:cop) { described_class.new } - context 'when the migration class inherits from BatchedMigrationJob' do it 'does not register any offenses' do expect_no_offenses(<<~RUBY) diff --git a/spec/rubocop/cop/migration/background_migration_record_spec.rb b/spec/rubocop/cop/migration/background_migration_record_spec.rb index b5724ef1efd..d5a451e00c9 100644 --- a/spec/rubocop/cop/migration/background_migration_record_spec.rb +++ b/spec/rubocop/cop/migration/background_migration_record_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/background_migration_record' RSpec.describe RuboCop::Cop::Migration::BackgroundMigrationRecord do - subject(:cop) { described_class.new } - context 'outside of a migration' do it 'does not register any offenses' do expect_no_offenses(<<~SOURCE) diff --git a/spec/rubocop/cop/migration/background_migrations_spec.rb b/spec/rubocop/cop/migration/background_migrations_spec.rb index 3242211ab47..681bbd84562 100644 --- a/spec/rubocop/cop/migration/background_migrations_spec.rb +++ b/spec/rubocop/cop/migration/background_migrations_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/background_migrations' RSpec.describe RuboCop::Cop::Migration::BackgroundMigrations do diff --git a/spec/rubocop/cop/migration/complex_indexes_require_name_spec.rb b/spec/rubocop/cop/migration/complex_indexes_require_name_spec.rb index ac814c10550..7329d399330 100644 --- a/spec/rubocop/cop/migration/complex_indexes_require_name_spec.rb +++ b/spec/rubocop/cop/migration/complex_indexes_require_name_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true # -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/complex_indexes_require_name' RSpec.describe RuboCop::Cop::Migration::ComplexIndexesRequireName do - subject(:cop) { described_class.new } - context 'when in migration' do let(:msg) { 'indexes added with custom options must be explicitly named' } diff --git a/spec/rubocop/cop/migration/create_table_with_foreign_keys_spec.rb b/spec/rubocop/cop/migration/create_table_with_foreign_keys_spec.rb index 6a8df2b507d..072edb5827b 100644 --- a/spec/rubocop/cop/migration/create_table_with_foreign_keys_spec.rb +++ b/spec/rubocop/cop/migration/create_table_with_foreign_keys_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/create_table_with_foreign_keys' RSpec.describe RuboCop::Cop::Migration::CreateTableWithForeignKeys do @@ -192,7 +192,7 @@ RSpec.describe RuboCop::Cop::Migration::CreateTableWithForeignKeys do include_context 'when there is a target to a high traffic table', :foreign_key do let(:explicit_target_opts) { ", to_table: :#{table_name}" } - let(:implicit_target_opts) { } + let(:implicit_target_opts) {} end end end diff --git a/spec/rubocop/cop/migration/datetime_spec.rb b/spec/rubocop/cop/migration/datetime_spec.rb index 95a875b3baa..400abe3be70 100644 --- a/spec/rubocop/cop/migration/datetime_spec.rb +++ b/spec/rubocop/cop/migration/datetime_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/datetime' RSpec.describe RuboCop::Cop::Migration::Datetime do - subject(:cop) { described_class.new } - let(:create_table_migration_without_datetime) do %q( class Users < ActiveRecord::Migration[6.0] diff --git a/spec/rubocop/cop/migration/drop_table_spec.rb b/spec/rubocop/cop/migration/drop_table_spec.rb index f1bd710f5e6..dd5f93eaafc 100644 --- a/spec/rubocop/cop/migration/drop_table_spec.rb +++ b/spec/rubocop/cop/migration/drop_table_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/drop_table' RSpec.describe RuboCop::Cop::Migration::DropTable do - subject(:cop) { described_class.new } - context 'when in deployment migration' do let(:msg) do '`drop_table` in deployment migrations requires downtime. Drop tables in post-deployment migrations instead.' diff --git a/spec/rubocop/cop/migration/migration_record_spec.rb b/spec/rubocop/cop/migration/migration_record_spec.rb index bfe6228c421..96a1d8fa107 100644 --- a/spec/rubocop/cop/migration/migration_record_spec.rb +++ b/spec/rubocop/cop/migration/migration_record_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/migration_record' RSpec.describe RuboCop::Cop::Migration::MigrationRecord do - subject(:cop) { described_class.new } - shared_examples 'a disabled cop' do |klass| it 'does not register any offenses' do expect_no_offenses(<<~SOURCE) diff --git a/spec/rubocop/cop/migration/prevent_global_enable_lock_retries_with_disable_ddl_transaction_spec.rb b/spec/rubocop/cop/migration/prevent_global_enable_lock_retries_with_disable_ddl_transaction_spec.rb index aa63259288d..1035ed2fb4a 100644 --- a/spec/rubocop/cop/migration/prevent_global_enable_lock_retries_with_disable_ddl_transaction_spec.rb +++ b/spec/rubocop/cop/migration/prevent_global_enable_lock_retries_with_disable_ddl_transaction_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/prevent_global_enable_lock_retries_with_disable_ddl_transaction' RSpec.describe RuboCop::Cop::Migration::PreventGlobalEnableLockRetriesWithDisableDdlTransaction do - subject(:cop) { described_class.new } - context 'when in migration' do before do allow(cop).to receive(:in_migration?).and_return(true) diff --git a/spec/rubocop/cop/migration/prevent_index_creation_spec.rb b/spec/rubocop/cop/migration/prevent_index_creation_spec.rb index ed7c8974d8d..9d886467a48 100644 --- a/spec/rubocop/cop/migration/prevent_index_creation_spec.rb +++ b/spec/rubocop/cop/migration/prevent_index_creation_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/prevent_index_creation' RSpec.describe RuboCop::Cop::Migration::PreventIndexCreation do - subject(:cop) { described_class.new } - let(:forbidden_tables) { %w(ci_builds) } let(:forbidden_tables_list) { forbidden_tables.join(', ') } diff --git a/spec/rubocop/cop/migration/prevent_strings_spec.rb b/spec/rubocop/cop/migration/prevent_strings_spec.rb index d1760c2db88..f1adeae6786 100644 --- a/spec/rubocop/cop/migration/prevent_strings_spec.rb +++ b/spec/rubocop/cop/migration/prevent_strings_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/prevent_strings' RSpec.describe RuboCop::Cop::Migration::PreventStrings do - subject(:cop) { described_class.new } - context 'when in migration' do before do allow(cop).to receive(:in_migration?).and_return(true) diff --git a/spec/rubocop/cop/migration/refer_to_index_by_name_spec.rb b/spec/rubocop/cop/migration/refer_to_index_by_name_spec.rb index c65f86d1e13..acdc6843584 100644 --- a/spec/rubocop/cop/migration/refer_to_index_by_name_spec.rb +++ b/spec/rubocop/cop/migration/refer_to_index_by_name_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true # -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/refer_to_index_by_name' RSpec.describe RuboCop::Cop::Migration::ReferToIndexByName do - subject(:cop) { described_class.new } - context 'when in migration' do before do allow(cop).to receive(:in_migration?).and_return(true) diff --git a/spec/rubocop/cop/migration/remove_column_spec.rb b/spec/rubocop/cop/migration/remove_column_spec.rb index f72a5b048d5..4aa842969fe 100644 --- a/spec/rubocop/cop/migration/remove_column_spec.rb +++ b/spec/rubocop/cop/migration/remove_column_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/remove_column' RSpec.describe RuboCop::Cop::Migration::RemoveColumn do - subject(:cop) { described_class.new } - def source(meth = 'change') "def #{meth}; remove_column :table, :column; end" end diff --git a/spec/rubocop/cop/migration/remove_concurrent_index_spec.rb b/spec/rubocop/cop/migration/remove_concurrent_index_spec.rb index 10ca0353b0f..1d59390d659 100644 --- a/spec/rubocop/cop/migration/remove_concurrent_index_spec.rb +++ b/spec/rubocop/cop/migration/remove_concurrent_index_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/remove_concurrent_index' RSpec.describe RuboCop::Cop::Migration::RemoveConcurrentIndex do - subject(:cop) { described_class.new } - context 'in migration' do before do allow(cop).to receive(:in_migration?).and_return(true) diff --git a/spec/rubocop/cop/migration/remove_index_spec.rb b/spec/rubocop/cop/migration/remove_index_spec.rb index 5d1ffef2589..24823b47d53 100644 --- a/spec/rubocop/cop/migration/remove_index_spec.rb +++ b/spec/rubocop/cop/migration/remove_index_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/remove_index' RSpec.describe RuboCop::Cop::Migration::RemoveIndex do - subject(:cop) { described_class.new } - context 'when in migration' do before do allow(cop).to receive(:in_migration?).and_return(true) diff --git a/spec/rubocop/cop/migration/safer_boolean_column_spec.rb b/spec/rubocop/cop/migration/safer_boolean_column_spec.rb index cf9bdbeef91..2050051cac7 100644 --- a/spec/rubocop/cop/migration/safer_boolean_column_spec.rb +++ b/spec/rubocop/cop/migration/safer_boolean_column_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/safer_boolean_column' RSpec.describe RuboCop::Cop::Migration::SaferBooleanColumn do - subject(:cop) { described_class.new } - context 'in migration' do before do allow(cop).to receive(:in_migration?).and_return(true) diff --git a/spec/rubocop/cop/migration/schedule_async_spec.rb b/spec/rubocop/cop/migration/schedule_async_spec.rb index 09d2c77369c..59e03db07c0 100644 --- a/spec/rubocop/cop/migration/schedule_async_spec.rb +++ b/spec/rubocop/cop/migration/schedule_async_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/schedule_async' diff --git a/spec/rubocop/cop/migration/sidekiq_queue_migrate_spec.rb b/spec/rubocop/cop/migration/sidekiq_queue_migrate_spec.rb index 499351b3585..46c460b5d49 100644 --- a/spec/rubocop/cop/migration/sidekiq_queue_migrate_spec.rb +++ b/spec/rubocop/cop/migration/sidekiq_queue_migrate_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/sidekiq_queue_migrate' RSpec.describe RuboCop::Cop::Migration::SidekiqQueueMigrate do - subject(:cop) { described_class.new } - def source(meth = 'change') "def #{meth}; sidekiq_queue_migrate 'queue', to: 'new_queue'; end" end diff --git a/spec/rubocop/cop/migration/timestamps_spec.rb b/spec/rubocop/cop/migration/timestamps_spec.rb index 2f99a3ff35b..706fd8a3d0f 100644 --- a/spec/rubocop/cop/migration/timestamps_spec.rb +++ b/spec/rubocop/cop/migration/timestamps_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/timestamps' RSpec.describe RuboCop::Cop::Migration::Timestamps do - subject(:cop) { described_class.new } - let(:migration_with_timestamps) do %q( class Users < ActiveRecord::Migration[4.2] diff --git a/spec/rubocop/cop/migration/update_column_in_batches_spec.rb b/spec/rubocop/cop/migration/update_column_in_batches_spec.rb index a12ae94c22b..005d3fb6b2a 100644 --- a/spec/rubocop/cop/migration/update_column_in_batches_spec.rb +++ b/spec/rubocop/cop/migration/update_column_in_batches_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/update_column_in_batches' diff --git a/spec/rubocop/cop/migration/versioned_migration_class_spec.rb b/spec/rubocop/cop/migration/versioned_migration_class_spec.rb index d9b0cd4546c..b44f5d64a62 100644 --- a/spec/rubocop/cop/migration/versioned_migration_class_spec.rb +++ b/spec/rubocop/cop/migration/versioned_migration_class_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/versioned_migration_class' RSpec.describe RuboCop::Cop::Migration::VersionedMigrationClass do - subject(:cop) { described_class.new } - let(:migration) do <<~SOURCE class TestMigration < Gitlab::Database::Migration[1.0] 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 298ca273256..5762f78820c 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 @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/with_lock_retries_disallowed_method' RSpec.describe RuboCop::Cop::Migration::WithLockRetriesDisallowedMethod do - subject(:cop) { described_class.new } - context 'when in migration' do before do allow(cop).to receive(:in_migration?).and_return(true) diff --git a/spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb b/spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb index f2e84a8697c..fed9176ea97 100644 --- a/spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb +++ b/spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/migration/with_lock_retries_with_change' RSpec.describe RuboCop::Cop::Migration::WithLockRetriesWithChange do - subject(:cop) { described_class.new } - context 'when in migration' do before do allow(cop).to receive(:in_migration?).and_return(true) |