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 ...@@ -17,7 +17,7 @@ RSpec.describe Gitlab::Database::QueryAnalyzers::GitlabSchemasMetrics, query_ana
process_sql(ActiveRecord::Base, "SELECT 1 FROM projects") process_sql(ActiveRecord::Base, "SELECT 1 FROM projects")
end end
context 'properly observes all queries', :mocked_ci_connection do context 'properly observes all queries', :add_ci_connection do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
where do where do
......
...@@ -51,8 +51,9 @@ module Database ...@@ -51,8 +51,9 @@ module Database
end end
# rubocop:enable Database/MultipleDatabases # rubocop:enable Database/MultipleDatabases
def with_mocked_ci_connection def with_added_ci_connection
if Gitlab::Database.has_config?(:ci) if Gitlab::Database.has_config?(:ci)
# No need to add a ci: connection if we already have one
yield yield
else else
with_reestablished_active_record_base(reconnect: true) do with_reestablished_active_record_base(reconnect: true) do
...@@ -92,8 +93,8 @@ RSpec.configure do |config| ...@@ -92,8 +93,8 @@ RSpec.configure do |config|
end end
end end
config.around(:each, :mocked_ci_connection) do |example| config.around(:each, :add_ci_connection) do |example|
with_mocked_ci_connection do with_added_ci_connection do
example.run example.run
end end
end end
......
...@@ -57,7 +57,7 @@ RSpec.describe 'Database::MultipleDatabases' do ...@@ -57,7 +57,7 @@ RSpec.describe 'Database::MultipleDatabases' do
end end
end end
describe '.with_mocked_ci_connection' do describe '.with_added_ci_connection' do
context 'when only a single database is setup' do context 'when only a single database is setup' do
before do before do
skip_if_multiple_databases_are_setup skip_if_multiple_databases_are_setup
...@@ -67,7 +67,7 @@ RSpec.describe 'Database::MultipleDatabases' do ...@@ -67,7 +67,7 @@ RSpec.describe 'Database::MultipleDatabases' do
main_database = current_database(ActiveRecord::Base) main_database = current_database(ActiveRecord::Base)
original_database = current_database(Ci::ApplicationRecord) 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) expect(current_database(Ci::ApplicationRecord)).to eq(main_database)
end end
...@@ -83,7 +83,7 @@ RSpec.describe 'Database::MultipleDatabases' do ...@@ -83,7 +83,7 @@ RSpec.describe 'Database::MultipleDatabases' do
it 'does not mock the original Ci::ApplicationRecord connection', :aggregate_failures do it 'does not mock the original Ci::ApplicationRecord connection', :aggregate_failures do
original_database = current_database(Ci::ApplicationRecord) 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) expect(current_database(Ci::ApplicationRecord)).to eq(original_database)
end 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