Permalink
Browse files

Merge pull request #10424 from markevich/fix_test_prepare

Restore ActiveRecord connection to original environment after rake:db:test:prepare task.
  • Loading branch information...
rafaelfranca committed May 2, 2013
1 parent c178177 commit 57584e4f03aa0e9d9b68c210b88bd0c6095e35f4
Showing with 7 additions and 3 deletions.
  1. +7 −3 activerecord/lib/active_record/railties/databases.rake
@@ -321,9 +321,13 @@ db_namespace = namespace :db do
# desc "Recreate the test database from an existent schema.rb file"
task :load_schema => 'db:test:purge' do
- ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
- ActiveRecord::Schema.verbose = false
- db_namespace["schema:load"].invoke
+ begin
+ ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
+ ActiveRecord::Schema.verbose = false
+ db_namespace["schema:load"].invoke
+ ensure
+ ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[Rails.env])
+ end
end
# desc "Recreate the test database from an existent structure.sql file"

0 comments on commit 57584e4

Please sign in to comment.