Commit 5b9d733a authored by Tetiana Chupryna's avatar Tetiana Chupryna

Merge branch '352770-fix-dev-setup-for-multiple-dbs' into 'master'

Fix dev:setup task for multiple databases

See merge request gitlab-org/gitlab!81327
parents 36e79a9d e23e1541
......@@ -8,8 +8,10 @@ namespace :dev do
ENV['force'] = 'yes'
Rake::Task["gitlab:setup"].invoke
# Make sure DB statistics are up to date.
ActiveRecord::Base.connection.execute('ANALYZE')
Gitlab::Database::EachDatabase.each_database_connection do |connection|
# Make sure DB statistics are up to date.
connection.execute('ANALYZE')
end
Rake::Task["gitlab:shell:setup"].invoke
end
......
# frozen_string_literal: true
require 'rake_helper'
RSpec.describe 'dev rake tasks' do
before do
Rake.application.rake_require 'tasks/gitlab/setup'
Rake.application.rake_require 'tasks/gitlab/shell'
Rake.application.rake_require 'tasks/dev'
end
describe 'setup' do
subject(:setup_task) { run_rake_task('dev:setup') }
let(:connections) { Gitlab::Database.database_base_models.values.map(&:connection) }
it 'sets up the development environment', :aggregate_failures do
expect(Rake::Task['gitlab:setup']).to receive(:invoke)
expect(connections).to all(receive(:execute).with('ANALYZE'))
expect(Rake::Task['gitlab:shell:setup']).to receive(:invoke)
setup_task
end
end
describe 'load' do
subject(:load_task) { run_rake_task('dev:load') }
it 'eager loads the application', :aggregate_failures do
expect(Rails.configuration).to receive(:eager_load=).with(true)
expect(Rails.application).to receive(:eager_load!)
load_task
end
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