diff options
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/environments/test.rb | 6 | ||||
-rw-r--r-- | railties/lib/initializer.rb | 28 |
3 files changed, 35 insertions, 1 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 44b349e68f..6a1fb77408 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -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) diff --git a/railties/environments/test.rb b/railties/environments/test.rb index 5402d88f81..66b823dc6c 100644 --- a/railties/environments/test.rb +++ b/railties/environments/test.rb @@ -15,3 +15,9 @@ config.action_controller.perform_caching = false # 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
\ No newline at end of file diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index f6be1bb1ea..0e786dfa5d 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -36,6 +36,7 @@ module Rails load_environment initialize_database + initialize_fixture_settings if configuration.environment == 'test' initialize_logger initialize_framework_logging initialize_framework_views @@ -100,6 +101,15 @@ module Rails 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 @@ module Rails 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 @@ module Rails 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 @@ module Rails 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 |