Skip to content
代码片段 群组 项目
提交 acd2f8fa 编辑于 作者: Thong Kuah's avatar Thong Kuah
浏览文件

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

上级 6eeb7b3e
无相关合并请求
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
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 @@ def with_reestablished_active_record_base(reconnect: true) ...@@ -51,8 +51,9 @@ def with_reestablished_active_record_base(reconnect: true)
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 @@ def establish_connection(*args) ...@@ -92,8 +93,8 @@ def establish_connection(*args)
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 @@ ...@@ -57,7 +57,7 @@
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 @@ ...@@ -67,7 +67,7 @@
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 @@ ...@@ -83,7 +83,7 @@
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
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册