Permalink
Browse files

db:test:clone and prepare must load environment

db:test:clone and db:test:prepare use
ActiveRecord::Base. configurations, so we need to load the rails
environment, otherwise the config wont be in place.
  • Loading branch information...
1 parent 12affbe commit b3a806b7b2179fc588465fee728fe837cf8d4940 @arthurnn arthurnn committed Dec 13, 2013
Showing with 9 additions and 3 deletions.
  1. +7 −0 activerecord/CHANGELOG.md
  2. +2 −3 activerecord/lib/active_record/railties/databases.rake
@@ -1,3 +1,10 @@
+* db:test:clone and db:test:prepare must load Rails environment
+
+ db:test:clone and db:test:prepare use ActiveRecord::Base. configurations,
+ so we need to load the rails environment, otherwise the config wont be in place.
+
+ *arthurnn*
+
* Create a whitelist of delegable methods to `Array`.
Currently `Relation` directly delegates methods to `Array`. With this change,
@@ -343,7 +343,7 @@ db_namespace = namespace :db do
end
# desc "Recreate the test database from a fresh schema"
- task :clone do
+ task :clone => :environment do
case ActiveRecord::Base.schema_format
when :ruby
db_namespace["test:clone_schema"].invoke
@@ -364,7 +364,7 @@ db_namespace = namespace :db do
end
# desc 'Check for pending migrations and load the test schema'
- task :prepare => :load_config do
+ task :prepare => [:environment, :load_config] do
unless ActiveRecord::Base.configurations.blank?
db_namespace['test:load'].invoke
end
@@ -401,4 +401,3 @@ namespace :railties do
end
task 'test:prepare' => ['db:test:prepare', 'db:test:load', 'db:abort_if_pending_migrations']
-

0 comments on commit b3a806b

Please sign in to comment.