Permalink
Browse files

rake:db:test:prepare falls back to original environment after execution.

  • Loading branch information...
1 parent ca2bc30 commit 56445c9075e22fdf00b534363c0744c78d6037f0 @markevich markevich committed May 2, 2013
Showing with 11 additions and 3 deletions.
  1. +4 −0 activerecord/CHANGELOG.md
  2. +7 −3 activerecord/lib/active_record/railties/databases.rake
@@ -35,5 +35,9 @@
* Abort a rake task when missing db/structure.sql like `db:schema:load` task.
*kennyj*
+
+* rake:db:test:prepare falls back to original environment after execution.
+
+ *Slava Markevich*
Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/activerecord/CHANGELOG.md) for previous changes.
@@ -319,9 +319,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 56445c9

Please sign in to comment.