aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-06-28 23:51:50 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-06-28 23:51:50 +0000
commitce458a74a5f95bb09c4e6b6dbd62367d767af18e (patch)
tree40d4afe7a37428c17b24690dcc4795c05b5c6d76
parent0e146d54a7b31d571fe3b5d2e62085a432d7e52c (diff)
downloadrails-ce458a74a5f95bb09c4e6b6dbd62367d767af18e.tar.gz
rails-ce458a74a5f95bb09c4e6b6dbd62367d767af18e.tar.bz2
rails-ce458a74a5f95bb09c4e6b6dbd62367d767af18e.zip
Don't assume Active Record is available. Closes #5497.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4505 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rwxr-xr-xactiverecord/lib/active_record/fixtures.rb2
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/tasks/databases.rake24
3 files changed, 17 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 3180d91c46..66cf3f237b 100755
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -505,6 +505,7 @@ module Test #:nodoc:
end
def setup_with_fixtures
+ return if !defined?(ActiveRecord::Base) || ActiveRecord::Base.configurations.blank?
if pre_loaded_fixtures && !use_transactional_fixtures
raise RuntimeError, 'pre_loaded_fixtures requires use_transactional_fixtures'
end
@@ -535,6 +536,7 @@ module Test #:nodoc:
alias_method :setup, :setup_with_fixtures
def teardown_with_fixtures
+ return if !defined?(ActiveRecord::Base) || ActiveRecord::Base.configurations.blank?
# Rollback changes.
if use_transactional_fixtures?
ActiveRecord::Base.connection.rollback_db_transaction
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 507b3a0219..ca87f29f01 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Don't assume Active Record is available. #5497 [bob@sporkmonger.com]
+
* Mongrel: script/server works on Win32. #5499 [jeremydurham@gmail.com]
* Remove opts.on { |options[:option_name] } style hash assignment. Closes #4440. [nicksieger@gmail.com]
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake
index 4394febd03..98d5555404 100644
--- a/railties/lib/tasks/databases.rake
+++ b/railties/lib/tasks/databases.rake
@@ -5,16 +5,16 @@ namespace :db do
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
end
- namespace :fixtures do
- desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y"
- task :load => :environment do
- require 'active_record/fixtures'
- ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
- (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'test', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
- Fixtures.create_fixtures('test/fixtures', File.basename(fixture_file, '.*'))
- end
- end
- end
+ namespace :fixtures do
+ desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y"
+ task :load => :environment do
+ require 'active_record/fixtures'
+ ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'test', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
+ Fixtures.create_fixtures('test/fixtures', File.basename(fixture_file, '.*'))
+ end
+ end
+ end
namespace :schema do
desc "Create a db/schema.rb file that can be portably used against any DB supported by AR"
@@ -136,7 +136,9 @@ namespace :db do
desc 'Prepare the test database and load the schema'
task :prepare => :environment do
- Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:clone" }[ActiveRecord::Base.schema_format]].invoke
+ if defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank?
+ Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:clone" }[ActiveRecord::Base.schema_format]].invoke
+ end
end
end