Commit acd2f8fa authored by Thong Kuah's avatar Thong Kuah

Rename to more accurate name for adding a CI connection if not present

parent 6eeb7b3e
......@@ -17,7 +17,7 @@ RSpec.describe Gitlab::Database::QueryAnalyzers::GitlabSchemasMetrics, query_ana
process_sql(ActiveRecord::Base, "SELECT 1 FROM projects")
end
context 'properly observes all queries', :mocked_ci_connection do
context 'properly observes all queries', :add_ci_connection do
using RSpec::Parameterized::TableSyntax
where do
......
......@@ -51,8 +51,9 @@ module Database
end
# rubocop:enable Database/MultipleDatabases
def with_mocked_ci_connection
def with_added_ci_connection
if Gitlab::Database.has_config?(:ci)
# No need to add a ci: connection if we already have one
yield
else
with_reestablished_active_record_base(reconnect: true) do
......@@ -92,8 +93,8 @@ RSpec.configure do |config|
end
end
config.around(:each, :mocked_ci_connection) do |example|
with_mocked_ci_connection do
config.around(:each, :add_ci_connection) do |example|
with_added_ci_connection do
example.run
end
end
......
......@@ -57,7 +57,7 @@ RSpec.describe 'Database::MultipleDatabases' do
end
end
describe '.with_mocked_ci_connection' do
describe '.with_added_ci_connection' do
context 'when only a single database is setup' do
before do
skip_if_multiple_databases_are_setup
......@@ -67,7 +67,7 @@ RSpec.describe 'Database::MultipleDatabases' do
main_database = current_database(ActiveRecord::Base)
original_database = current_database(Ci::ApplicationRecord)
with_mocked_ci_connection do
with_added_ci_connection do
expect(current_database(Ci::ApplicationRecord)).to eq(main_database)
end
......@@ -83,7 +83,7 @@ RSpec.describe 'Database::MultipleDatabases' do
it 'does not mock the original Ci::ApplicationRecord connection', :aggregate_failures do
original_database = current_database(Ci::ApplicationRecord)
with_mocked_ci_connection do
with_added_ci_connection do
expect(current_database(Ci::ApplicationRecord)).to eq(original_database)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment