debian-mirror-gitlab/spec/initializers/database_config_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.1 KiB
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
require 'spec_helper'
2021-11-18 22:05:49 +05:30
RSpec.describe 'Database config initializer', :reestablished_active_record_base do
2019-12-26 22:10:19 +05:30
subject do
load Rails.root.join('config/initializers/database_config.rb')
end
2023-03-04 22:38:38 +05:30
shared_examples 'does not change connection attributes' do
it 'retains the correct database name for connection' do
previous_db_name = database_base_model.connection.pool.db_config.name
2019-12-26 22:10:19 +05:30
2023-03-04 22:38:38 +05:30
subject
2021-09-04 01:27:46 +05:30
2023-03-04 22:38:38 +05:30
expect(database_base_model.connection.pool.db_config.name).to eq(previous_db_name)
end
it 'does not overwrite custom pool settings' do
expect { subject }.not_to change { database_base_model.connection_db_config.pool }
end
end
context 'when main database connection' do
let(:database_base_model) { Gitlab::Database.database_base_models[:main] }
it_behaves_like 'does not change connection attributes'
2020-10-24 23:57:45 +05:30
end
2019-12-26 22:10:19 +05:30
2023-03-04 22:38:38 +05:30
context 'when ci database connection' do
before do
skip_if_multiple_databases_not_setup
end
let(:database_base_model) { Gitlab::Database.database_base_models[:ci] }
it_behaves_like 'does not change connection attributes'
2019-12-26 22:10:19 +05:30
end
end