mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
commit
33671d30f4
2 changed files with 21 additions and 0 deletions
|
@ -265,6 +265,8 @@ db_namespace = namespace :db do
|
|||
end
|
||||
abort %{Run `rails db:migrate` to update your database then try again.}
|
||||
end
|
||||
ensure
|
||||
ActiveRecord::Base.establish_connection(ActiveRecord::Tasks::DatabaseTasks.env.to_sym)
|
||||
end
|
||||
|
||||
namespace :abort_if_pending_migrations do
|
||||
|
|
|
@ -349,6 +349,25 @@ module ApplicationTests
|
|||
rails "db:drop" rescue nil
|
||||
end
|
||||
end
|
||||
|
||||
test "db:seed uses primary database connection" do
|
||||
@old_rails_env = ENV["RAILS_ENV"]
|
||||
@old_rack_env = ENV["RACK_ENV"]
|
||||
ENV.delete "RAILS_ENV"
|
||||
ENV.delete "RACK_ENV"
|
||||
|
||||
db_migrate_and_schema_dump_and_load "schema"
|
||||
|
||||
app_file "db/seeds.rb", <<-RUBY
|
||||
print Book.connection.pool.spec.config[:database]
|
||||
RUBY
|
||||
|
||||
output = rails("db:seed")
|
||||
assert_equal output, "db/development.sqlite3"
|
||||
ensure
|
||||
ENV["RAILS_ENV"] = @old_rails_env
|
||||
ENV["RACK_ENV"] = @old_rack_env
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue