diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-04 16:39:01 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-04 16:47:35 +0200 |
commit | 92661b0c501a65b7f2d9ac8fbf9743152b8a031b (patch) | |
tree | b49e621c5db5b3ba72a1952577c863193b916e16 /railties/test/application | |
parent | b9bba555caa95389e97bd7d32472ddc1e429d7c2 (diff) | |
download | rails-92661b0c501a65b7f2d9ac8fbf9743152b8a031b.tar.gz rails-92661b0c501a65b7f2d9ac8fbf9743152b8a031b.tar.bz2 rails-92661b0c501a65b7f2d9ac8fbf9743152b8a031b.zip |
Move sandbox to AR and pass the sandbox as a value. This way, other ORMs like Datamapper can also have their own sandboxing in rails console.
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/console_test.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/railties/test/application/console_test.rb b/railties/test/application/console_test.rb index 793e73556c..5ae6323345 100644 --- a/railties/test/application/console_test.rb +++ b/railties/test/application/console_test.rb @@ -8,9 +8,9 @@ class ConsoleTest < Test::Unit::TestCase boot_rails end - def load_environment + def load_environment(sandbox = false) require "#{rails_root}/config/environment" - Rails.application.load_console + Rails.application.load_console(sandbox) end def test_app_method_should_return_integration_session @@ -73,6 +73,20 @@ class ConsoleTest < Test::Unit::TestCase helper.truncate('Once upon a time in a world far far away') end + def test_with_sandbox + require 'rails/all' + value = false + + Class.new(Rails::Railtie) do + console do |sandbox| + value = sandbox + end + end + + load_environment(true) + assert value + end + def test_active_record_does_not_panic_when_referencing_an_observed_constant add_to_config "config.active_record.observers = :user_observer" |