Permalink
Browse files

Made the instantiated/transactional fixtures settings be controlled t…

…hrough Rails::Initializer. Transactional and non-instantiated fixtures are default from now on.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2588 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 0065697 commit 9285f6c7ae3e4addf940b033713e6d0e09ae1540 @csshsh csshsh committed Oct 14, 2005
Showing with 35 additions and 1 deletion.
  1. +2 −0 railties/CHANGELOG
  2. +6 −0 railties/environments/test.rb
  3. +27 −1 railties/lib/initializer.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* Made the instantiated/transactional fixtures settings be controlled through Rails::Initializer. Transactional and non-instantiated fixtures are default from now on. [Florian Weber]
+
* Support using different database adapters for development and test with ActiveRecord::Base.schema_format = :ruby [Sam Stephenson]
* Make webrick work with session(:off)
@@ -15,3 +15,9 @@
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
+
+# Overwrite the default settings for fixtures in tests. See Fixtures
+# for more details about these settings.
+# config.transactional_fixtures = true
+# config.instantiated_fixtures = false
+# config.pre_loaded_fixtures = false
@@ -36,6 +36,7 @@ def process
load_environment
initialize_database
+ initialize_fixture_settings if configuration.environment == 'test'
initialize_logger
initialize_framework_logging
initialize_framework_views
@@ -100,6 +101,15 @@ def initialize_database
ActiveRecord::Base.establish_connection
end
+ def initialize_fixture_settings
+ return unless configuration.frameworks.include?(:active_record)
+ require 'test/unit'
+ require 'active_record/fixtures'
+ Test::Unit::TestCase.use_transactional_fixtures = configuration.transactional_fixtures
+ Test::Unit::TestCase.use_instantiated_fixtures = configuration.instantiated_fixtures
+ Test::Unit::TestCase.pre_loaded_fixtures = configuration.pre_loaded_fixtures
+ end
+
def initialize_logger
# if the environment has explicitly defined a logger, use it
return if defined?(RAILS_DEFAULT_LOGGER)
@@ -172,6 +182,7 @@ def intitialize_framework_settings
class Configuration
attr_accessor :frameworks, :load_paths, :logger, :log_level, :log_path, :database_configuration_file, :view_path, :controller_paths
attr_accessor :cache_classes, :breakpoint_server, :whiny_nils
+ attr_accessor :transactional_fixtures, :instantiated_fixtures, :pre_loaded_fixtures
attr_accessor :connection_adapters
attr_accessor :active_record, :action_controller, :action_view, :action_mailer, :action_web_service
@@ -186,7 +197,10 @@ def initialize
self.breakpoint_server = default_breakpoint_server
self.whiny_nils = default_whiny_nils
self.database_configuration_file = default_database_configuration_file
-
+ self.transactional_fixtures = default_transactional_fixtures
+ self.instantiated_fixtures = default_use_instantiated_fixtures
+ self.pre_loaded_fixtures = default_pre_loaded_fixtures
+
for framework in default_frameworks
self.send("#{framework}=", OrderedOptions.new)
end
@@ -278,6 +292,18 @@ def default_breakpoint_server
def default_whiny_nils
false
end
+
+ def default_transactional_fixtures
+ true
+ end
+
+ def default_use_instantiated_fixtures
+ false
+ end
+
+ def default_pre_loaded_fixtures
+ false
+ end
end
end

0 comments on commit 9285f6c

Please sign in to comment.