summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-11-05 15:11:48 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-05 15:11:48 +0000
commit81a37f05815a4c731a2d2c93302ddc554444b637 (patch)
tree447d3a8890961e63efc47280ac15f06c9c0567ff /spec
parentf7406657b9ed27af2970a88ce4f73c35b162dfb8 (diff)
downloadgitlab-ce-81a37f05815a4c731a2d2c93302ddc554444b637.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/background_migration/copy_column_using_background_migration_job_spec.rb2
-rw-r--r--spec/lib/gitlab/container_repository/tags/cache_spec.rb (renamed from spec/services/projects/container_repository/cache_tags_created_at_service_spec.rb)2
-rw-r--r--spec/lib/gitlab/database/background_migration/batched_migration_runner_spec.rb2
-rw-r--r--spec/lib/gitlab/database/load_balancing/connection_proxy_spec.rb6
-rw-r--r--spec/lib/gitlab/database/load_balancing_spec.rb8
-rw-r--r--spec/lib/gitlab/database/migration_helpers/loose_foreign_key_helpers_spec.rb10
-rw-r--r--spec/lib/gitlab/database/migration_helpers/v2_spec.rb62
-rw-r--r--spec/lib/gitlab/database/partitioning/monthly_strategy_spec.rb42
-rw-r--r--spec/lib/gitlab/database/schema_cache_with_renamed_table_spec.rb12
-rw-r--r--spec/lib/gitlab/graphql/pagination/connections_spec.rb6
-rw-r--r--spec/models/concerns/bulk_insert_safe_spec.rb22
-rw-r--r--spec/models/concerns/bulk_insertable_associations_spec.rb32
-rw-r--r--spec/models/concerns/where_composite_spec.rb2
-rw-r--r--spec/models/group_spec.rb10
-rw-r--r--spec/policies/project_policy_spec.rb22
-rw-r--r--spec/requests/projects/google_cloud_controller_spec.rb94
-rw-r--r--spec/services/ci/external_pull_requests/create_pipeline_service_spec.rb22
-rw-r--r--spec/services/loose_foreign_keys/batch_cleaner_service_spec.rb32
-rw-r--r--spec/support/shared_examples/namespaces/traversal_scope_examples.rb20
-rw-r--r--spec/tasks/gitlab/db_rake_spec.rb4
-rw-r--r--spec/workers/loose_foreign_keys/cleanup_worker_spec.rb50
21 files changed, 249 insertions, 213 deletions
diff --git a/spec/lib/gitlab/background_migration/copy_column_using_background_migration_job_spec.rb b/spec/lib/gitlab/background_migration/copy_column_using_background_migration_job_spec.rb
index 3e378db04d4..d4fc24d0559 100644
--- a/spec/lib/gitlab/background_migration/copy_column_using_background_migration_job_spec.rb
+++ b/spec/lib/gitlab/background_migration/copy_column_using_background_migration_job_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe Gitlab::BackgroundMigration::CopyColumnUsingBackgroundMigrationJob do
- let(:table_name) { :copy_primary_key_test }
+ let(:table_name) { :_test_copy_primary_key_test }
let(:test_table) { table(table_name) }
let(:sub_batch_size) { 1000 }
let(:pause_ms) { 0 }
diff --git a/spec/services/projects/container_repository/cache_tags_created_at_service_spec.rb b/spec/lib/gitlab/container_repository/tags/cache_spec.rb
index dfe2ff9e57c..f84c1ce173f 100644
--- a/spec/services/projects/container_repository/cache_tags_created_at_service_spec.rb
+++ b/spec/lib/gitlab/container_repository/tags/cache_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe ::Projects::ContainerRepository::CacheTagsCreatedAtService, :clean_gitlab_redis_cache do
+RSpec.describe ::Gitlab::ContainerRepository::Tags::Cache, :clean_gitlab_redis_cache do
let_it_be(:dummy_tag_class) { Struct.new(:name, :created_at) }
let_it_be(:repository) { create(:container_repository) }
diff --git a/spec/lib/gitlab/database/background_migration/batched_migration_runner_spec.rb b/spec/lib/gitlab/database/background_migration/batched_migration_runner_spec.rb
index 779e8e40c97..04c18a98ee6 100644
--- a/spec/lib/gitlab/database/background_migration/batched_migration_runner_spec.rb
+++ b/spec/lib/gitlab/database/background_migration/batched_migration_runner_spec.rb
@@ -286,7 +286,7 @@ RSpec.describe Gitlab::Database::BackgroundMigration::BatchedMigrationRunner do
let(:migration_wrapper) { Gitlab::Database::BackgroundMigration::BatchedMigrationWrapper.new }
let(:migration_helpers) { ActiveRecord::Migration.new }
- let(:table_name) { :_batched_migrations_test_table }
+ let(:table_name) { :_test_batched_migrations_test_table }
let(:column_name) { :some_id }
let(:job_arguments) { [:some_id, :some_id_convert_to_bigint] }
diff --git a/spec/lib/gitlab/database/load_balancing/connection_proxy_spec.rb b/spec/lib/gitlab/database/load_balancing/connection_proxy_spec.rb
index ba2f9485066..b81f9c26421 100644
--- a/spec/lib/gitlab/database/load_balancing/connection_proxy_spec.rb
+++ b/spec/lib/gitlab/database/load_balancing/connection_proxy_spec.rb
@@ -85,7 +85,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::ConnectionProxy do
describe '.insert_all!' do
before do
ActiveRecord::Schema.define do
- create_table :connection_proxy_bulk_insert, force: true do |t|
+ create_table :_test_connection_proxy_bulk_insert, force: true do |t|
t.string :name, null: true
end
end
@@ -93,13 +93,13 @@ RSpec.describe Gitlab::Database::LoadBalancing::ConnectionProxy do
after do
ActiveRecord::Schema.define do
- drop_table :connection_proxy_bulk_insert, force: true
+ drop_table :_test_connection_proxy_bulk_insert, force: true
end
end
let(:model_class) do
Class.new(ApplicationRecord) do
- self.table_name = "connection_proxy_bulk_insert"
+ self.table_name = "_test_connection_proxy_bulk_insert"
end
end
diff --git a/spec/lib/gitlab/database/load_balancing_spec.rb b/spec/lib/gitlab/database/load_balancing_spec.rb
index bbadcf73b10..d1b811deca9 100644
--- a/spec/lib/gitlab/database/load_balancing_spec.rb
+++ b/spec/lib/gitlab/database/load_balancing_spec.rb
@@ -105,7 +105,7 @@ RSpec.describe Gitlab::Database::LoadBalancing do
describe 'LoadBalancing integration tests', :database_replica, :delete do
before(:all) do
ActiveRecord::Schema.define do
- create_table :load_balancing_test, force: true do |t|
+ create_table :_test_load_balancing_test, force: true do |t|
t.string :name, null: true
end
end
@@ -113,13 +113,13 @@ RSpec.describe Gitlab::Database::LoadBalancing do
after(:all) do
ActiveRecord::Schema.define do
- drop_table :load_balancing_test, force: true
+ drop_table :_test_load_balancing_test, force: true
end
end
let(:model) do
Class.new(ApplicationRecord) do
- self.table_name = "load_balancing_test"
+ self.table_name = "_test_load_balancing_test"
end
end
@@ -443,7 +443,7 @@ RSpec.describe Gitlab::Database::LoadBalancing do
elsif payload[:name] == 'SQL' # Custom query
true
else
- keywords = %w[load_balancing_test]
+ keywords = %w[_test_load_balancing_test]
keywords += %w[begin commit] if include_transaction
keywords.any? { |keyword| payload[:sql].downcase.include?(keyword) }
end
diff --git a/spec/lib/gitlab/database/migration_helpers/loose_foreign_key_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers/loose_foreign_key_helpers_spec.rb
index 54b3ad22faf..f1dbfbbff18 100644
--- a/spec/lib/gitlab/database/migration_helpers/loose_foreign_key_helpers_spec.rb
+++ b/spec/lib/gitlab/database/migration_helpers/loose_foreign_key_helpers_spec.rb
@@ -9,18 +9,18 @@ RSpec.describe Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers do
let(:model) do
Class.new(ApplicationRecord) do
- self.table_name = 'loose_fk_test_table'
+ self.table_name = '_test_loose_fk_test_table'
end
end
before(:all) do
- migration.create_table :loose_fk_test_table do |t|
+ migration.create_table :_test_loose_fk_test_table do |t|
t.timestamps
end
end
after(:all) do
- migration.drop_table :loose_fk_test_table
+ migration.drop_table :_test_loose_fk_test_table
end
before do
@@ -37,7 +37,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers do
context 'when the record deletion tracker trigger is installed' do
before do
- migration.track_record_deletions(:loose_fk_test_table)
+ migration.track_record_deletions(:_test_loose_fk_test_table)
end
it 'stores the record deletion' do
@@ -50,7 +50,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers do
deleted_record = LooseForeignKeys::DeletedRecord.all.first
expect(deleted_record.primary_key_value).to eq(record_to_be_deleted.id)
- expect(deleted_record.fully_qualified_table_name).to eq('public.loose_fk_test_table')
+ expect(deleted_record.fully_qualified_table_name).to eq('public._test_loose_fk_test_table')
expect(deleted_record.partition).to eq(1)
end
diff --git a/spec/lib/gitlab/database/migration_helpers/v2_spec.rb b/spec/lib/gitlab/database/migration_helpers/v2_spec.rb
index 854e97ef897..acf775b3538 100644
--- a/spec/lib/gitlab/database/migration_helpers/v2_spec.rb
+++ b/spec/lib/gitlab/database/migration_helpers/v2_spec.rb
@@ -20,7 +20,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers::V2 do
let(:model) { Class.new(ActiveRecord::Base) }
before do
- model.table_name = :test_table
+ model.table_name = :_test_table
end
context 'when called inside a transaction block' do
@@ -30,19 +30,19 @@ RSpec.describe Gitlab::Database::MigrationHelpers::V2 do
it 'raises an error' do
expect do
- migration.public_send(operation, :test_table, :original, :renamed)
+ migration.public_send(operation, :_test_table, :original, :renamed)
end.to raise_error("#{operation} can not be run inside a transaction")
end
end
context 'when the existing column has a default value' do
before do
- migration.change_column_default :test_table, existing_column, 'default value'
+ migration.change_column_default :_test_table, existing_column, 'default value'
end
it 'raises an error' do
expect do
- migration.public_send(operation, :test_table, :original, :renamed)
+ migration.public_send(operation, :_test_table, :original, :renamed)
end.to raise_error("#{operation} does not currently support columns with default values")
end
end
@@ -51,18 +51,18 @@ RSpec.describe Gitlab::Database::MigrationHelpers::V2 do
context 'when the batch column does not exist' do
it 'raises an error' do
expect do
- migration.public_send(operation, :test_table, :original, :renamed, batch_column_name: :missing)
- end.to raise_error('Column missing does not exist on test_table')
+ migration.public_send(operation, :_test_table, :original, :renamed, batch_column_name: :missing)
+ end.to raise_error('Column missing does not exist on _test_table')
end
end
context 'when the batch column does exist' do
it 'passes it when creating the column' do
expect(migration).to receive(:create_column_from)
- .with(:test_table, existing_column, added_column, type: nil, batch_column_name: :status)
+ .with(:_test_table, existing_column, added_column, type: nil, batch_column_name: :status)
.and_call_original
- migration.public_send(operation, :test_table, :original, :renamed, batch_column_name: :status)
+ migration.public_send(operation, :_test_table, :original, :renamed, batch_column_name: :status)
end
end
end
@@ -71,17 +71,17 @@ RSpec.describe Gitlab::Database::MigrationHelpers::V2 do
existing_record_1 = model.create!(status: 0, existing_column => 'existing')
existing_record_2 = model.create!(status: 0, existing_column => nil)
- migration.send(operation, :test_table, :original, :renamed)
+ migration.send(operation, :_test_table, :original, :renamed)
model.reset_column_information
- expect(migration.column_exists?(:test_table, added_column)).to eq(true)
+ expect(migration.column_exists?(:_test_table, added_column)).to eq(true)
expect(existing_record_1.reload).to have_attributes(status: 0, original: 'existing', renamed: 'existing')
expect(existing_record_2.reload).to have_attributes(status: 0, original: nil, renamed: nil)
end
it 'installs triggers to sync new data' do
- migration.public_send(operation, :test_table, :original, :renamed)
+ migration.public_send(operation, :_test_table, :original, :renamed)
model.reset_column_information
new_record_1 = model.create!(status: 1, original: 'first')
@@ -102,7 +102,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers::V2 do
before do
allow(migration).to receive(:transaction_open?).and_return(false)
- migration.create_table :test_table do |t|
+ migration.create_table :_test_table do |t|
t.integer :status, null: false
t.text :original
t.text :other_column
@@ -118,8 +118,8 @@ RSpec.describe Gitlab::Database::MigrationHelpers::V2 do
context 'when the column to rename does not exist' do
it 'raises an error' do
expect do
- migration.rename_column_concurrently :test_table, :missing_column, :renamed
- end.to raise_error('Column missing_column does not exist on test_table')
+ migration.rename_column_concurrently :_test_table, :missing_column, :renamed
+ end.to raise_error('Column missing_column does not exist on _test_table')
end
end
end
@@ -128,7 +128,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers::V2 do
before do
allow(migration).to receive(:transaction_open?).and_return(false)
- migration.create_table :test_table do |t|
+ migration.create_table :_test_table do |t|
t.integer :status, null: false
t.text :other_column
t.text :renamed
@@ -144,8 +144,8 @@ RSpec.describe Gitlab::Database::MigrationHelpers::V2 do
context 'when the renamed column does not exist' do
it 'raises an error' do
expect do
- migration.undo_cleanup_concurrent_column_rename :test_table, :original, :missing_column
- end.to raise_error('Column missing_column does not exist on test_table')
+ migration.undo_cleanup_concurrent_column_rename :_test_table, :original, :missing_column
+ end.to raise_error('Column missing_column does not exist on _test_table')
end
end
end
@@ -156,25 +156,25 @@ RSpec.describe Gitlab::Database::MigrationHelpers::V2 do
before do
allow(migration).to receive(:transaction_open?).and_return(false)
- migration.create_table :test_table do |t|
+ migration.create_table :_test_table do |t|
t.integer :status, null: false
t.text :original
t.text :other_column
end
- migration.rename_column_concurrently :test_table, :original, :renamed
+ migration.rename_column_concurrently :_test_table, :original, :renamed
end
context 'when the helper is called repeatedly' do
before do
- migration.public_send(operation, :test_table, :original, :renamed)
+ migration.public_send(operation, :_test_table, :original, :renamed)
end
it 'does not make repeated attempts to cleanup' do
expect(migration).not_to receive(:remove_column)
expect do
- migration.public_send(operation, :test_table, :original, :renamed)
+ migration.public_send(operation, :_test_table, :original, :renamed)
end.not_to raise_error
end
end
@@ -182,26 +182,26 @@ RSpec.describe Gitlab::Database::MigrationHelpers::V2 do
context 'when the renamed column exists' do
let(:triggers) do
[
- ['trigger_7cc71f92fd63', 'function_for_trigger_7cc71f92fd63', before: 'insert'],
- ['trigger_f1a1f619636a', 'function_for_trigger_f1a1f619636a', before: 'update'],
- ['trigger_769a49938884', 'function_for_trigger_769a49938884', before: 'update']
+ ['trigger_020dbcb8cdd0', 'function_for_trigger_020dbcb8cdd0', before: 'insert'],
+ ['trigger_6edaca641d03', 'function_for_trigger_6edaca641d03', before: 'update'],
+ ['trigger_a3fb9f3add34', 'function_for_trigger_a3fb9f3add34', before: 'update']
]
end
it 'removes the sync triggers and renamed columns' do
triggers.each do |(trigger_name, function_name, event)|
expect_function_to_exist(function_name)
- expect_valid_function_trigger(:test_table, trigger_name, function_name, event)
+ expect_valid_function_trigger(:_test_table, trigger_name, function_name, event)
end
- expect(migration.column_exists?(:test_table, added_column)).to eq(true)
+ expect(migration.column_exists?(:_test_table, added_column)).to eq(true)
- migration.public_send(operation, :test_table, :original, :renamed)
+ migration.public_send(operation, :_test_table, :original, :renamed)
- expect(migration.column_exists?(:test_table, added_column)).to eq(false)
+ expect(migration.column_exists?(:_test_table, added_column)).to eq(false)
triggers.each do |(trigger_name, function_name, _)|
- expect_trigger_not_to_exist(:test_table, trigger_name)
+ expect_trigger_not_to_exist(:_test_table, trigger_name)
expect_function_not_to_exist(function_name)
end
end
@@ -223,7 +223,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers::V2 do
end
describe '#create_table' do
- let(:table_name) { :test_table }
+ let(:table_name) { :_test_table }
let(:column_attributes) do
[
{ name: 'id', sql_type: 'bigint', null: false, default: nil },
@@ -245,7 +245,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers::V2 do
end
expect_table_columns_to_match(column_attributes, table_name)
- expect_check_constraint(table_name, 'check_cda6f69506', 'char_length(name) <= 100')
+ expect_check_constraint(table_name, 'check_e9982cf9da', 'char_length(name) <= 100')
end
end
end
diff --git a/spec/lib/gitlab/database/partitioning/monthly_strategy_spec.rb b/spec/lib/gitlab/database/partitioning/monthly_strategy_spec.rb
index 27ada12b067..67d80d71e2a 100644
--- a/spec/lib/gitlab/database/partitioning/monthly_strategy_spec.rb
+++ b/spec/lib/gitlab/database/partitioning/monthly_strategy_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe Gitlab::Database::Partitioning::MonthlyStrategy do
let(:model) { double('model', table_name: table_name) }
let(:partitioning_key) { double }
- let(:table_name) { :partitioned_test }
+ let(:table_name) { :_test_partitioned_test }
before do
connection.execute(<<~SQL)
@@ -18,11 +18,11 @@ RSpec.describe Gitlab::Database::Partitioning::MonthlyStrategy do
(id serial not null, created_at timestamptz not null, PRIMARY KEY (id, created_at))
PARTITION BY RANGE (created_at);
- CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}.partitioned_test_000000
+ CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}._test_partitioned_test_000000
PARTITION OF #{table_name}
FOR VALUES FROM (MINVALUE) TO ('2020-05-01');
- CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}.partitioned_test_202005
+ CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}._test_partitioned_test_202005
PARTITION OF #{table_name}
FOR VALUES FROM ('2020-05-01') TO ('2020-06-01');
SQL
@@ -30,8 +30,8 @@ RSpec.describe Gitlab::Database::Partitioning::MonthlyStrategy do
it 'detects both partitions' do
expect(subject).to eq([
- Gitlab::Database::Partitioning::TimePartition.new(table_name, nil, '2020-05-01', partition_name: 'partitioned_test_000000'),
- Gitlab::Database::Partitioning::TimePartition.new(table_name, '2020-05-01', '2020-06-01', partition_name: 'partitioned_test_202005')
+ Gitlab::Database::Partitioning::TimePartition.new(table_name, nil, '2020-05-01', partition_name: '_test_partitioned_test_000000'),
+ Gitlab::Database::Partitioning::TimePartition.new(table_name, '2020-05-01', '2020-06-01', partition_name: '_test_partitioned_test_202005')
])
end
end
@@ -41,7 +41,7 @@ RSpec.describe Gitlab::Database::Partitioning::MonthlyStrategy do
let(:model) do
Class.new(ActiveRecord::Base) do
- self.table_name = 'partitioned_test'
+ self.table_name = '_test_partitioned_test'
self.primary_key = :id
end
end
@@ -59,11 +59,11 @@ RSpec.describe Gitlab::Database::Partitioning::MonthlyStrategy do
(id serial not null, created_at timestamptz not null, PRIMARY KEY (id, created_at))
PARTITION BY RANGE (created_at);
- CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}.partitioned_test_000000
+ CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}._test_partitioned_test_000000
PARTITION OF #{model.table_name}
FOR VALUES FROM (MINVALUE) TO ('2020-05-01');
- CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}.partitioned_test_202006
+ CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}._test_partitioned_test_202006
PARTITION OF #{model.table_name}
FOR VALUES FROM ('2020-06-01') TO ('2020-07-01');
SQL
@@ -166,7 +166,7 @@ RSpec.describe Gitlab::Database::Partitioning::MonthlyStrategy do
(id serial not null, created_at timestamptz not null, PRIMARY KEY (id, created_at))
PARTITION BY RANGE (created_at);
- CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}.partitioned_test_202006
+ CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}._test_partitioned_test_202006
PARTITION OF #{model.table_name}
FOR VALUES FROM ('2020-06-01') TO ('2020-07-01');
SQL
@@ -181,13 +181,13 @@ RSpec.describe Gitlab::Database::Partitioning::MonthlyStrategy do
describe '#extra_partitions' do
let(:model) do
Class.new(ActiveRecord::Base) do
- self.table_name = 'partitioned_test'
+ self.table_name = '_test_partitioned_test'
self.primary_key = :id
end
end
let(:partitioning_key) { :created_at }
- let(:table_name) { :partitioned_test }
+ let(:table_name) { :_test_partitioned_test }
around do |example|
travel_to(Date.parse('2020-08-22')) { example.run }
@@ -200,15 +200,15 @@ RSpec.describe Gitlab::Database::Partitioning::MonthlyStrategy do
(id serial not null, created_at timestamptz not null, PRIMARY KEY (id, created_at))
PARTITION BY RANGE (created_at);
- CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}.partitioned_test_000000
+ CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}._test_partitioned_test_000000
PARTITION OF #{table_name}
FOR VALUES FROM (MINVALUE) TO ('2020-05-01');
- CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}.partitioned_test_202005
+ CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}._test_partitioned_test_202005
PARTITION OF #{table_name}
FOR VALUES FROM ('2020-05-01') TO ('2020-06-01');
- CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}.partitioned_test_202006
+ CREATE TABLE #{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}._test_partitioned_test_202006
PARTITION OF #{table_name}
FOR VALUES FROM ('2020-06-01') TO ('2020-07-01')
SQL
@@ -235,7 +235,7 @@ RSpec.describe Gitlab::Database::Partitioning::MonthlyStrategy do
it 'prunes the unbounded partition ending 2020-05-01' do
min_value_to_may = Gitlab::Database::Partitioning::TimePartition.new(model.table_name, nil, '2020-05-01',
- partition_name: 'partitioned_test_000000')
+ partition_name: '_test_partitioned_test_000000')
expect(subject).to contain_exactly(min_value_to_may)
end
@@ -246,8 +246,8 @@ RSpec.describe Gitlab::Database::Partitioning::MonthlyStrategy do
it 'prunes the unbounded partition and the partition for May-June' do
expect(subject).to contain_exactly(
- Gitlab::Database::Partitioning::TimePartition.new(model.table_name, nil, '2020-05-01', partition_name: 'partitioned_test_000000'),
- Gitlab::Database::Partitioning::TimePartition.new(model.table_name, '2020-05-01', '2020-06-01', partition_name: 'partitioned_test_202005')
+ Gitlab::Database::Partitioning::TimePartition.new(model.table_name, nil, '2020-05-01', partition_name: '_test_partitioned_test_000000'),
+ Gitlab::Database::Partitioning::TimePartition.new(model.table_name, '2020-05-01', '2020-06-01', partition_name: '_test_partitioned_test_202005')
)
end
@@ -256,16 +256,16 @@ RSpec.describe Gitlab::Database::Partitioning::MonthlyStrategy do
it 'prunes empty partitions' do
expect(subject).to contain_exactly(
- Gitlab::Database::Partitioning::TimePartition.new(model.table_name, nil, '2020-05-01', partition_name: 'partitioned_test_000000'),
- Gitlab::Database::Partitioning::TimePartition.new(model.table_name, '2020-05-01', '2020-06-01', partition_name: 'partitioned_test_202005')
+ Gitlab::Database::Partitioning::TimePartition.new(model.table_name, nil, '2020-05-01', partition_name: '_test_partitioned_test_000000'),
+ Gitlab::Database::Partitioning::TimePartition.new(model.table_name, '2020-05-01', '2020-06-01', partition_name: '_test_partitioned_test_202005')
)
end
it 'does not prune non-empty partitions' do
- connection.execute("INSERT INTO #{table_name} (created_at) VALUES (('2020-05-15'))") # inserting one record into partitioned_test_202005
+ connection.execute("INSERT INTO #{table_name} (created_at) VALUES (('2020-05-15'))") # inserting one record into _test_partitioned_test_202005
expect(subject).to contain_exactly(
- Gitlab::Database::Partitioning::TimePartition.new(model.table_name, nil, '2020-05-01', partition_name: 'partitioned_test_000000')
+ Gitlab::Database::Partitioning::TimePartition.new(model.table_name, nil, '2020-05-01', partition_name: '_test_partitioned_test_000000')
)
end
end
diff --git a/spec/lib/gitlab/database/schema_cache_with_renamed_table_spec.rb b/spec/lib/gitlab/database/schema_cache_with_renamed_table_spec.rb
index 8c0c4155ccc..7caee414719 100644
--- a/spec/lib/gitlab/database/schema_cache_with_renamed_table_spec.rb
+++ b/spec/lib/gitlab/database/schema_cache_with_renamed_table_spec.rb
@@ -11,12 +11,12 @@ RSpec.describe Gitlab::Database::SchemaCacheWithRenamedTable do
let(:new_model) do
Class.new(ActiveRecord::Base) do
- self.table_name = 'projects_new'
+ self.table_name = '_test_projects_new'
end
end
before do
- stub_const('Gitlab::Database::TABLES_TO_BE_RENAMED', { 'projects' => 'projects_new' })
+ stub_const('Gitlab::Database::TABLES_TO_BE_RENAMED', { 'projects' => '_test_projects_new' })
end
context 'when table is not renamed yet' do
@@ -32,8 +32,8 @@ RSpec.describe Gitlab::Database::SchemaCacheWithRenamedTable do
context 'when table is renamed' do
before do
- ActiveRecord::Base.connection.execute("ALTER TABLE projects RENAME TO projects_new")
- ActiveRecord::Base.connection.execute("CREATE VIEW projects AS SELECT * FROM projects_new")
+ ActiveRecord::Base.connection.execute("ALTER TABLE projects RENAME TO _test_projects_new")
+ ActiveRecord::Base.connection.execute("CREATE VIEW projects AS SELECT * FROM _test_projects_new")
old_model.reset_column_information
ActiveRecord::Base.connection.schema_cache.clear!
@@ -54,14 +54,14 @@ RSpec.describe Gitlab::Database::SchemaCacheWithRenamedTable do
it 'has the same indexes' do
indexes_for_old_table = ActiveRecord::Base.connection.schema_cache.indexes('projects')
- indexes_for_new_table = ActiveRecord::Base.connection.schema_cache.indexes('projects_new')
+ indexes_for_new_table = ActiveRecord::Base.connection.schema_cache.indexes('_test_projects_new')
expect(indexes_for_old_table).to eq(indexes_for_new_table)
end
it 'has the same column_hash' do
columns_hash_for_old_table = ActiveRecord::Base.connection.schema_cache.columns_hash('projects')
- columns_hash_for_new_table = ActiveRecord::Base.connection.schema_cache.columns_hash('projects_new')
+ columns_hash_for_new_table = ActiveRecord::Base.connection.schema_cache.columns_hash('_test_projects_new')
expect(columns_hash_for_old_table).to eq(columns_hash_for_new_table)
end
diff --git a/spec/lib/gitlab/graphql/pagination/connections_spec.rb b/spec/lib/gitlab/graphql/pagination/connections_spec.rb
index f3f59113c81..97389b6250e 100644
--- a/spec/lib/gitlab/graphql/pagination/connections_spec.rb
+++ b/spec/lib/gitlab/graphql/pagination/connections_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe ::Gitlab::Graphql::Pagination::Connections do
before(:all) do
ActiveRecord::Schema.define do
- create_table :testing_pagination_nodes, force: true do |t|
+ create_table :_test_testing_pagination_nodes, force: true do |t|
t.integer :value, null: false
end
end
@@ -16,13 +16,13 @@ RSpec.describe ::Gitlab::Graphql::Pagination::Connections do
after(:all) do
ActiveRecord::Schema.define do
- drop_table :testing_pagination_nodes, force: true
+ drop_table :_test_testing_pagination_nodes, force: true
end
end
let_it_be(:node_model) do
Class.new(ActiveRecord::Base) do
- self.table_name = 'testing_pagination_nodes'
+ self.table_name = '_test_testing_pagination_nodes'
end
end
diff --git a/spec/models/concerns/bulk_insert_safe_spec.rb b/spec/models/concerns/bulk_insert_safe_spec.rb
index 172986c142c..f5c70abf5e9 100644
--- a/spec/models/concerns/bulk_insert_safe_spec.rb
+++ b/spec/models/concerns/bulk_insert_safe_spec.rb
@@ -5,42 +5,42 @@ require 'spec_helper'
RSpec.describe BulkInsertSafe do
before(:all) do
ActiveRecord::Schema.define do
- create_table :bulk_insert_parent_items, force: true do |t|
+ create_table :_test_bulk_insert_parent_items, force: true do |t|
t.string :name, null: false
end
- create_table :bulk_insert_items, force: true do |t|
+ create_table :_test_bulk_insert_items, force: true do |t|
t.string :name, null: true
t.integer :enum_value, null: false
t.text :encrypted_secret_value, null: false
t.string :encrypted_secret_value_iv, null: false
t.binary :sha_value, null: false, limit: 20
t.jsonb :jsonb_value, null: false
- t.belongs_to :bulk_insert_parent_item, foreign_key: true, null: true
+ t.belongs_to :bulk_insert_parent_item, foreign_key: { to_table: :_test_bulk_insert_parent_items }, null: true
t.timestamps null: true
t.index :name, unique: true
end
- create_table :bulk_insert_items_with_composite_pk, id: false, force: true do |t|
+ create_table :_test_bulk_insert_items_with_composite_pk, id: false, force: true do |t|
t.integer :id, null: true
t.string :name, null: true
end
- execute("ALTER TABLE bulk_insert_items_with_composite_pk ADD PRIMARY KEY (id,name);")
+ execute("ALTER TABLE _test_bulk_insert_items_with_composite_pk ADD PRIMARY KEY (id,name);")
end
end
after(:all) do
ActiveRecord::Schema.define do
- drop_table :bulk_insert_items, force: true
- drop_table :bulk_insert_parent_items, force: true
- drop_table :bulk_insert_items_with_composite_pk, force: true
+ drop_table :_test_bulk_insert_items, force: true
+ drop_table :_test_bulk_insert_parent_items, force: true
+ drop_table :_test_bulk_insert_items_with_composite_pk, force: true
end
end
BulkInsertParentItem = Class.new(ActiveRecord::Base) do
- self.table_name = :bulk_insert_parent_items
+ self.table_name = :_test_bulk_insert_parent_items
self.inheritance_column = :_type_disabled
def self.name
@@ -54,7 +54,7 @@ RSpec.describe BulkInsertSafe do
let_it_be(:bulk_insert_item_class) do
Class.new(ActiveRecord::Base) do
- self.table_name = 'bulk_insert_items'
+ self.table_name = '_test_bulk_insert_items'
include BulkInsertSafe
include ShaAttribute
@@ -247,7 +247,7 @@ RSpec.describe BulkInsertSafe do
context 'when a model with composite primary key is inserted' do
let_it_be(:bulk_insert_items_with_composite_pk_class) do
Class.new(ActiveRecord::Base) do
- self.table_name = 'bulk_insert_items_with_composite_pk'
+ self.table_name = '_test_bulk_insert_items_with_composite_pk'
include BulkInsertSafe
end
diff --git a/spec/models/concerns/bulk_insertable_associations_spec.rb b/spec/models/concerns/bulk_insertable_associations_spec.rb
index 25b13c8233d..9713f1ce9a4 100644
--- a/spec/models/concerns/bulk_insertable_associations_spec.rb
+++ b/spec/models/concerns/bulk_insertable_associations_spec.rb
@@ -6,42 +6,50 @@ RSpec.describe BulkInsertableAssociations do
class BulkFoo < ApplicationRecord
include BulkInsertSafe
+ self.table_name = '_test_bulk_foos'
+
validates :name, presence: true
end
class BulkBar < ApplicationRecord
include BulkInsertSafe
+
+ self.table_name = '_test_bulk_bars'
end
- SimpleBar = Class.new(ApplicationRecord)
+ SimpleBar = Class.new(ApplicationRecord) do
+ self.table_name = '_test_simple_bars'
+ end
class BulkParent < ApplicationRecord
include BulkInsertableAssociations
- has_many :bulk_foos
+ self.table_name = '_test_bulk_parents'
+
+ has_many :bulk_foos, class_name: 'BulkFoo'
has_many :bulk_hunks, class_name: 'BulkFoo'
- has_many :bulk_bars
- has_many :simple_bars # not `BulkInsertSafe`
+ has_many :bulk_bars, class_name: 'BulkBar'
+ has_many :simple_bars, class_name: 'SimpleBar' # not `BulkInsertSafe`
has_one :bulk_foo # not supported
end
before(:all) do
ActiveRecord::Schema.define do
- create_table :bulk_parents, force: true do |t|
+ create_table :_test_bulk_parents, force: true do |t|
t.string :name, null: true
end
- create_table :bulk_foos, force: true do |t|
+ create_table :_test_bulk_foos, force: true do |t|
t.string :name, null: true
t.belongs_to :bulk_parent, null: false
end
- create_table :bulk_bars, force: true do |t|
+ create_table :_test_bulk_bars, force: true do |t|
t.string :name, null: true
t.belongs_to :bulk_parent, null: false
end
- create_table :simple_bars, force: true do |t|
+ create_table :_test_simple_bars, force: true do |t|
t.string :name, null: true
t.belongs_to :bulk_parent, null: false
end
@@ -50,10 +58,10 @@ RSpec.describe BulkInsertableAssociations do
after(:all) do
ActiveRecord::Schema.define do
- drop_table :bulk_foos, force: true
- drop_table :bulk_bars, force: true
- drop_table :simple_bars, force: true
- drop_table :bulk_parents, force: true
+ drop_table :_test_bulk_foos, force: true
+ drop_table :_test_bulk_bars, force: true
+ drop_table :_test_simple_bars, force: true
+ drop_table :_test_bulk_parents, force: true
end
end
diff --git a/spec/models/concerns/where_composite_spec.rb b/spec/models/concerns/where_composite_spec.rb
index 5e67f2f5b65..6abdd12aac5 100644
--- a/spec/models/concerns/where_composite_spec.rb
+++ b/spec/models/concerns/where_composite_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe WhereComposite do
describe '.where_composite' do
- let_it_be(:test_table_name) { "test_table_#{SecureRandom.hex(10)}" }
+ let_it_be(:test_table_name) { "_test_table_#{SecureRandom.hex(10)}" }
let(:model) do
tbl_name = test_table_name
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 6b6e68ab937..ce0442f27a3 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -571,16 +571,6 @@ RSpec.describe Group do
it 'filters out project namespace' do
expect(group.descendants.find_by_id(project_namespace.id)).to be_nil
end
-
- context 'when include_sti_condition is disabled' do
- before do
- stub_feature_flags(include_sti_condition: false)
- end
-
- it 'raises an exception' do
- expect { group.descendants.find_by_id(project_namespace.id)}.to raise_error(ActiveRecord::SubclassNotFound)
- end
- end
end
end
end
diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb
index f36b0a62aa3..67d7e49f8db 100644
--- a/spec/policies/project_policy_spec.rb
+++ b/spec/policies/project_policy_spec.rb
@@ -955,6 +955,28 @@ RSpec.describe ProjectPolicy do
end
end
+ context 'infrastructure google cloud feature' do
+ %w(guest reporter developer).each do |role|
+ context role do
+ let(:current_user) { send(role) }
+
+ it 'disallows managing google cloud' do
+ expect_disallowed(:admin_project_google_cloud)
+ end
+ end
+ end
+
+ %w(maintainer owner).each do |role|
+ context role do
+ let(:current_user) { send(role) }
+
+ it 'allows managing google cloud' do
+ expect_allowed(:admin_project_google_cloud)
+ end
+ end
+ end
+ end
+
describe 'design permissions' do
include DesignManagementTestHelpers
diff --git a/spec/requests/projects/google_cloud_controller_spec.rb b/spec/requests/projects/google_cloud_controller_spec.rb
index 3b43f0d1dfb..37682152994 100644
--- a/spec/requests/projects/google_cloud_controller_spec.rb
+++ b/spec/requests/projects/google_cloud_controller_spec.rb
@@ -2,48 +2,106 @@
require 'spec_helper'
+# Mock Types
+MockGoogleOAuth2Credentials = Struct.new(:app_id, :app_secret)
+
RSpec.describe Projects::GoogleCloudController do
let_it_be(:project) { create(:project, :public) }
describe 'GET index' do
let_it_be(:url) { "#{project_google_cloud_index_path(project)}" }
- let(:subject) { get url }
+ context 'when a public request is made' do
+ it 'returns not found' do
+ get url
- context 'when user is authorized' do
- let(:user) { project.creator }
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
- before do
+ context 'when a project.guest makes request' do
+ let(:user) { create(:user) }
+
+ it 'returns not found' do
+ project.add_guest(user)
sign_in(user)
- subject
+
+ get url
+
+ expect(response).to have_gitlab_http_status(:not_found)
end
+ end
- it 'renders content' do
- expect(response).to be_successful
+ context 'when project.developer makes request' do
+ let(:user) { create(:user) }
+
+ it 'returns not found' do
+ project.add_developer(user)
+ sign_in(user)
+
+ get url
+
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'when user is unauthorized' do
+ context 'when project.maintainer makes request' do
let(:user) { create(:user) }
- before do
- project.add_guest(user)
+ it 'returns successful' do
+ project.add_maintainer(user)
sign_in(user)
- subject
+
+ get url
+
+ expect(response).to be_successful
end
+ end
- it 'shows 404' do
- expect(response).to have_gitlab_http_status(:not_found)
+ context 'when project.creator makes request' do
+ let(:user) { project.creator }
+
+ it 'returns successful' do
+ sign_in(user)
+
+ get url
+
+ expect(response).to be_successful
end
end
- context 'when no user is present' do
- before do
- subject
+ describe 'when authorized user makes request' do
+ let(:user) { project.creator }
+
+ context 'but gitlab instance is not configured for google oauth2' do
+ before do
+ unconfigured_google_oauth2 = MockGoogleOAuth2Credentials.new('', '')
+ allow(Gitlab::Auth::OAuth::Provider).to receive(:config_for)
+ .with('google_oauth2')
+ .and_return(unconfigured_google_oauth2)
+ end
+
+ it 'returns forbidden' do
+ sign_in(user)
+
+ get url
+
+ expect(response).to have_gitlab_http_status(:forbidden)
+ end
end
- it 'shows 404' do
- expect(response).to have_gitlab_http_status(:not_found)
+ context 'but feature flag is disabled' do
+ before do
+ stub_feature_flags(incubation_5mp_google_cloud: false)
+ end
+
+ it 'returns not found' do
+ sign_in(user)
+
+ get url
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
end
end
end
diff --git a/spec/services/ci/external_pull_requests/create_pipeline_service_spec.rb b/spec/services/ci/external_pull_requests/create_pipeline_service_spec.rb
index 04d75630295..d5881d3b204 100644
--- a/spec/services/ci/external_pull_requests/create_pipeline_service_spec.rb
+++ b/spec/services/ci/external_pull_requests/create_pipeline_service_spec.rb
@@ -26,28 +26,6 @@ RSpec.describe Ci::ExternalPullRequests::CreatePipelineService do
pull_request.update!(source_branch: source_branch.name, source_sha: source_branch.target)
end
- context 'when the FF ci_create_external_pr_pipeline_async is disabled' do
- before do
- stub_feature_flags(ci_create_external_pr_pipeline_async: false)
- end
-
- it 'creates a pipeline for external pull request', :aggregate_failures do
- pipeline = execute.payload
-
- expect(execute).to be_success
- expect(pipeline).to be_valid
- expect(pipeline).to be_persisted
- expect(pipeline).to be_external_pull_request_event
- expect(pipeline).to eq(project.ci_pipelines.last)
- expect(pipeline.external_pull_request).to eq(pull_request)
- expect(pipeline.user).to eq(user)
- expect(pipeline.status).to eq('created')
- expect(pipeline.ref).to eq(pull_request.source_branch)
- expect(pipeline.sha).to eq(pull_request.source_sha)
- expect(pipeline.source_sha).to eq(pull_request.source_sha)
- end
- end
-
it 'enqueues Ci::ExternalPullRequests::CreatePipelineWorker' do
expect { execute }
.to change { ::Ci::ExternalPullRequests::CreatePipelineWorker.jobs.count }
diff --git a/spec/services/loose_foreign_keys/batch_cleaner_service_spec.rb b/spec/services/loose_foreign_keys/batch_cleaner_service_spec.rb
index 409bbfb4098..bdb3d0f6700 100644
--- a/spec/services/loose_foreign_keys/batch_cleaner_service_spec.rb
+++ b/spec/services/loose_foreign_keys/batch_cleaner_service_spec.rb
@@ -8,44 +8,44 @@ RSpec.describe LooseForeignKeys::BatchCleanerService do
def create_table_structure
migration = ActiveRecord::Migration.new.extend(Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers)
- migration.create_table :loose_fk_parent_table
+ migration.create_table :_test_loose_fk_parent_table
- migration.create_table :loose_fk_child_table_1 do |t|
+ migration.create_table :_test_loose_fk_child_table_1 do |t|
t.bigint :parent_id
end
- migration.create_table :loose_fk_child_table_2 do |t|
+ migration.create_table :_test_loose_fk_child_table_2 do |t|
t.bigint :parent_id_with_different_column
end
- migration.track_record_deletions(:loose_fk_parent_table)
+ migration.track_record_deletions(:_test_loose_fk_parent_table)
end
let(:parent_model) do
Class.new(ApplicationRecord) do
- self.table_name = 'loose_fk_parent_table'
+ self.table_name = '_test_loose_fk_parent_table'
include LooseForeignKey
- loose_foreign_key :loose_fk_child_table_1, :parent_id, on_delete: :async_delete
- loose_foreign_key :loose_fk_child_table_2, :parent_id_with_different_column, on_delete: :async_nullify
+ loose_foreign_key :_test_loose_fk_child_table_1, :parent_id, on_delete: :async_delete
+ loose_foreign_key :_test_loose_fk_child_table_2, :parent_id_with_different_column, on_delete: :async_nullify
end
end
let(:child_model_1) do
Class.new(ApplicationRecord) do
- self.table_name = 'loose_fk_child_table_1'
+ self.table_name = '_test_loose_fk_child_table_1'
end
end
let(:child_model_2) do
Class.new(ApplicationRecord) do
- self.table_name = 'loose_fk_child_table_2'
+ self.table_name = '_test_loose_fk_child_table_2'
end
end
- let(:loose_fk_child_table_1) { table(:loose_fk_child_table_1) }
- let(:loose_fk_child_table_2) { table(:loose_fk_child_table_2) }
+ let(:loose_fk_child_table_1) { table(:_test_loose_fk_child_table_1) }
+ let(:loose_fk_child_table_2) { table(:_test_loose_fk_child_table_2) }
let(:parent_record_1) { parent_model.create! }
let(:other_parent_record) { parent_model.create! }
@@ -73,9 +73,9 @@ RSpec.describe LooseForeignKeys::BatchCleanerService do
after(:all) do
migration = ActiveRecord::Migration.new
- migration.drop_table :loose_fk_parent_table
- migration.drop_table :loose_fk_child_table_1
- migration.drop_table :loose_fk_child_table_2
+ migration.drop_table :_test_loose_fk_parent_table
+ migration.drop_table :_test_loose_fk_child_table_1
+ migration.drop_table :_test_loose_fk_child_table_2
end
context 'when parent records are deleted' do
@@ -90,8 +90,8 @@ RSpec.describe LooseForeignKeys::BatchCleanerService do
described_class.new(parent_klass: parent_model,
deleted_parent_records: LooseForeignKeys::DeletedRecord.status_pending.all,
models_by_table_name: {
- 'loose_fk_child_table_1' => child_model_1,
- 'loose_fk_child_table_2' => child_model_2
+ '_test_loose_fk_child_table_1' => child_model_1,
+ '_test_loose_fk_child_table_2' => child_model_2
}).execute
end
diff --git a/spec/support/shared_examples/namespaces/traversal_scope_examples.rb b/spec/support/shared_examples/namespaces/traversal_scope_examples.rb
index ba28ce1b45d..f797eea6b6e 100644
--- a/spec/support/shared_examples/namespaces/traversal_scope_examples.rb
+++ b/spec/support/shared_examples/namespaces/traversal_scope_examples.rb
@@ -25,26 +25,6 @@ RSpec.shared_examples 'namespace traversal scopes' do
it { is_expected.to contain_exactly(group_1.id, group_2.id) }
end
- describe '.without_sti_condition' do
- subject { described_class.where(type: 'Group').without_sti_condition }
-
- context 'when include_sti_condition is enabled' do
- before do
- stub_feature_flags(include_sti_condition: true)
- end
-
- it { expect(subject.where_values_hash).to have_key('type') }
- end
-
- context 'when include_sti_condition is disabled' do
- before do
- stub_feature_flags(include_sti_condition: false)
- end
-
- it { expect(subject.where_values_hash).not_to have_key('type') }
- end
- end
-
describe '.order_by_depth' do
subject { described_class.where(id: [group_1, nested_group_1, deep_nested_group_1]).order_by_depth(direction) }
diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb
index a273c8cfd7d..d051a5536e9 100644
--- a/spec/tasks/gitlab/db_rake_spec.rb
+++ b/spec/tasks/gitlab/db_rake_spec.rb
@@ -215,7 +215,7 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do
stub_feature_flags(database_async_index_creation: true)
expect(Gitlab::Database::AsyncIndexes).to receive(:create_pending_indexes!).ordered.exactly(databases_count).times
- expect(Gitlab::Database::Reindexing).to receive(:automatic_reindexing).ordered.once
+ expect(Gitlab::Database::Reindexing).to receive(:automatic_reindexing).ordered.exactly(databases_count).times
run_rake_task('gitlab:db:reindex')
end
@@ -233,7 +233,7 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do
context 'calls automatic reindexing' do
it 'uses all candidate indexes' do
- expect(Gitlab::Database::Reindexing).to receive(:automatic_reindexing).once
+ expect(Gitlab::Database::Reindexing).to receive(:automatic_reindexing).exactly(databases_count).times
run_rake_task('gitlab:db:reindex')
end
diff --git a/spec/workers/loose_foreign_keys/cleanup_worker_spec.rb b/spec/workers/loose_foreign_keys/cleanup_worker_spec.rb
index 574534a5d47..544be2a69a6 100644
--- a/spec/workers/loose_foreign_keys/cleanup_worker_spec.rb
+++ b/spec/workers/loose_foreign_keys/cleanup_worker_spec.rb
@@ -8,69 +8,69 @@ RSpec.describe LooseForeignKeys::CleanupWorker do
def create_table_structure
migration = ActiveRecord::Migration.new.extend(Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers)
- migration.create_table :loose_fk_parent_table_1
- migration.create_table :loose_fk_parent_table_2
+ migration.create_table :_test_loose_fk_parent_table_1
+ migration.create_table :_test_loose_fk_parent_table_2
- migration.create_table :loose_fk_child_table_1_1 do |t|
+ migration.create_table :_test_loose_fk_child_table_1_1 do |t|
t.bigint :parent_id
end
- migration.create_table :loose_fk_child_table_1_2 do |t|
+ migration.create_table :_test_loose_fk_child_table_1_2 do |t|
t.bigint :parent_id_with_different_column
end
- migration.create_table :loose_fk_child_table_2_1 do |t|
+ migration.create_table :_test_loose_fk_child_table_2_1 do |t|
t.bigint :parent_id
end
- migration.track_record_deletions(:loose_fk_parent_table_1)
- migration.track_record_deletions(:loose_fk_parent_table_2)
+ migration.track_record_deletions(:_test_loose_fk_parent_table_1)
+ migration.track_record_deletions(:_test_loose_fk_parent_table_2)
end
let!(:parent_model_1) do
Class.new(ApplicationRecord) do
- self.table_name = 'loose_fk_parent_table_1'
+ self.table_name = '_test_loose_fk_parent_table_1'
include LooseForeignKey
- loose_foreign_key :loose_fk_child_table_1_1, :parent_id, on_delete: :async_delete
- loose_foreign_key :loose_fk_child_table_1_2, :parent_id_with_different_column, on_delete: :async_nullify
+ loose_foreign_key :_test_loose_fk_child_table_1_1, :parent_id, on_delete: :async_delete
+ loose_foreign_key :_test_loose_fk_child_table_1_2, :parent_id_with_different_column, on_delete: :async_nullify
end
end
let!(:parent_model_2) do
Class.new(ApplicationRecord) do
- self.table_name = 'loose_fk_parent_table_2'
+ self.table_name = '_test_loose_fk_parent_table_2'
include LooseForeignKey
- loose_foreign_key :loose_fk_child_table_2_1, :parent_id, on_delete: :async_delete
+ loose_foreign_key :_test_loose_fk_child_table_2_1, :parent_id, on_delete: :async_delete
end
end
let!(:child_model_1) do
Class.new(ApplicationRecord) do
- self.table_name = 'loose_fk_child_table_1_1'
+ self.table_name = '_test_loose_fk_child_table_1_1'
end
end
let!(:child_model_2) do
Class.new(ApplicationRecord) do
- self.table_name = 'loose_fk_child_table_1_2'
+ self.table_name = '_test_loose_fk_child_table_1_2'
end
end
let!(:child_model_3) do
Class.new(ApplicationRecord) do
- self.table_name = 'loose_fk_child_table_2_1'
+ self.table_name = '_test_loose_fk_child_table_2_1'
end
end
- let(:loose_fk_parent_table_1) { table(:loose_fk_parent_table_1) }
- let(:loose_fk_parent_table_2) { table(:loose_fk_parent_table_2) }
- let(:loose_fk_child_table_1_1) { table(:loose_fk_child_table_1_1) }
- let(:loose_fk_child_table_1_2) { table(:loose_fk_child_table_1_2) }
- let(:loose_fk_child_table_2_1) { table(:loose_fk_child_table_2_1) }
+ let(:loose_fk_parent_table_1) { table(:_test_loose_fk_parent_table_1) }
+ let(:loose_fk_parent_table_2) { table(:_test_loose_fk_parent_table_2) }
+ let(:loose_fk_child_table_1_1) { table(:_test_loose_fk_child_table_1_1) }
+ let(:loose_fk_child_table_1_2) { table(:_test_loose_fk_child_table_1_2) }
+ let(:loose_fk_child_table_2_1) { table(:_test_loose_fk_child_table_2_1) }
before(:all) do
create_table_structure
@@ -79,11 +79,11 @@ RSpec.describe LooseForeignKeys::CleanupWorker do
after(:all) do
migration = ActiveRecord::Migration.new
- migration.drop_table :loose_fk_parent_table_1
- migration.drop_table :loose_fk_parent_table_2
- migration.drop_table :loose_fk_child_table_1_1
- migration.drop_table :loose_fk_child_table_1_2
- migration.drop_table :loose_fk_child_table_2_1
+ migration.drop_table :_test_loose_fk_parent_table_1
+ migration.drop_table :_test_loose_fk_parent_table_2
+ migration.drop_table :_test_loose_fk_child_table_1_1
+ migration.drop_table :_test_loose_fk_child_table_1_2
+ migration.drop_table :_test_loose_fk_child_table_2_1
end
before do