diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/tasks/gitlab/db_rake_spec.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/tasks/gitlab/db_rake_spec.rb')
-rw-r--r-- | spec/tasks/gitlab/db_rake_spec.rb | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb index e340d568269..d8199c09ca1 100644 --- a/spec/tasks/gitlab/db_rake_spec.rb +++ b/spec/tasks/gitlab/db_rake_spec.rb @@ -822,18 +822,20 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do let(:connection_pool) { instance_double(ActiveRecord::ConnectionAdapters::ConnectionPool ) } let(:connection) { instance_double(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) } let(:configurations) { double(ActiveRecord::DatabaseConfigurations) } - let(:configuration) { instance_double(ActiveRecord::DatabaseConfigurations::HashConfig) } + let(:configuration) { instance_double(ActiveRecord::DatabaseConfigurations::HashConfig, env_name: 'test', name: 'main') } let(:config_hash) { { username: 'foo' } } - it 'migrate as nonsuperuser check with default username' do + before do allow(Rake::Task['db:drop']).to receive(:invoke) allow(Rake::Task['db:create']).to receive(:invoke) allow(ActiveRecord::Base).to receive(:configurations).and_return(configurations) allow(configurations).to receive(:configs_for).and_return([configuration]) allow(configuration).to receive(:configuration_hash).and_return(config_hash) allow(ActiveRecord::Base).to receive(:establish_connection).and_return(connection_pool) + end - expect(config_hash).to receive(:merge).with({ username: 'gitlab' }) + it 'migrate as nonsuperuser check with default username' do + expect(config_hash).to receive(:merge).with({ username: 'gitlab' }).and_call_original expect(Gitlab::Database).to receive(:check_for_non_superuser) expect(Rake::Task['db:migrate']).to receive(:invoke) @@ -841,14 +843,7 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do end it 'migrate as nonsuperuser check with specified username' do - allow(Rake::Task['db:drop']).to receive(:invoke) - allow(Rake::Task['db:create']).to receive(:invoke) - allow(ActiveRecord::Base).to receive(:configurations).and_return(configurations) - allow(configurations).to receive(:configs_for).and_return([configuration]) - allow(configuration).to receive(:configuration_hash).and_return(config_hash) - allow(ActiveRecord::Base).to receive(:establish_connection).and_return(connection_pool) - - expect(config_hash).to receive(:merge).with({ username: 'foo' }) + expect(config_hash).to receive(:merge).with({ username: 'foo' }).and_call_original expect(Gitlab::Database).to receive(:check_for_non_superuser) expect(Rake::Task['db:migrate']).to receive(:invoke) |