diff options
author | José Valim <jose.valim@gmail.com> | 2010-07-17 10:59:41 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-07-18 11:02:07 +0200 |
commit | fa98eca75bd8666719bf3d061c87638850a20fe9 (patch) | |
tree | 8856316fd6c3bf49fc1ace113f6f62891701bc28 /railties/test/application | |
parent | cfca55949f51bf3970bae7c506807db97dbcf05f (diff) | |
download | rails-fa98eca75bd8666719bf3d061c87638850a20fe9.tar.gz rails-fa98eca75bd8666719bf3d061c87638850a20fe9.tar.bz2 rails-fa98eca75bd8666719bf3d061c87638850a20fe9.zip |
Add console hook to force ActiveRecord::Base to be loaded when console starts avoiding reference loops.
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/console_test.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/railties/test/application/console_test.rb b/railties/test/application/console_test.rb index 8ff69f0208..a72e6916dd 100644 --- a/railties/test/application/console_test.rb +++ b/railties/test/application/console_test.rb @@ -9,10 +9,8 @@ class ConsoleTest < Test::Unit::TestCase end def load_environment - # Load steps taken from rails/commands/console.rb require "#{rails_root}/config/environment" - require 'rails/console/app' - require 'rails/console/helpers' + Rails.application.load_console end def test_app_method_should_return_integration_session @@ -75,4 +73,21 @@ class ConsoleTest < Test::Unit::TestCase assert_equal 'Once upon a time in a world...', helper.truncate('Once upon a time in a world far far away') end + + def test_active_record_does_not_panic_when_referencing_an_observed_constant + add_to_config "config.active_record.observers = :user_observer" + + app_file "app/models/user.rb", <<-MODEL + class User < ActiveRecord::Base + end + MODEL + + app_file "app/models/user_observer.rb", <<-MODEL + class UserObserver < ActiveRecord::Observer + end + MODEL + + load_environment + assert_nothing_raised { User } + end end |