Does not create a dev:copy_db:geo task

parent 9e09dbac
......@@ -30,8 +30,10 @@ namespace :dev do
databases = ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml
namespace :copy_db do
ALLOWED_DATABASES = %w[ci].freeze
ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
next if name == 'main'
next unless ALLOWED_DATABASES.include?(name)
desc "Copies the #{name} database from the main database"
task name => :environment do
......
......@@ -40,10 +40,14 @@ RSpec.describe 'dev rake tasks' do
end
end
describe 'copy_db:ci' do
context 'multiple databases' do
before do
skip_if_multiple_databases_not_setup
end
context 'with a valid database' do
describe 'copy_db:ci' do
before do
configurations = instance_double(ActiveRecord::DatabaseConfigurations)
allow(ActiveRecord::Base).to receive(:configurations).and_return(configurations)
allow(configurations).to receive(:configs_for).with(env_name: Rails.env, name: 'ci').and_return(ci_configuration)
......@@ -70,4 +74,12 @@ RSpec.describe 'dev rake tasks' do
end
end
end
end
context 'with an invalid database' do
it 'raises an error' do
expect { run_rake_task('dev:copy_db:foo') }.to raise_error(RuntimeError, /Don't know how to build task/)
end
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