diff options
author | Lawrence Pit <lawrence.pit@gmail.com> | 2008-10-04 15:31:04 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-10-04 17:49:38 +0100 |
commit | 7659fb6a2b638703a99a63033d947d19089a6b85 (patch) | |
tree | 8fd60cdb04a6185be763433d0dfa9741972c70c7 /activerecord/test | |
parent | b437a7d34e86c16a211171d491e805b603f0dc99 (diff) | |
download | rails-7659fb6a2b638703a99a63033d947d19089a6b85.tar.gz rails-7659fb6a2b638703a99a63033d947d19089a6b85.tar.bz2 rails-7659fb6a2b638703a99a63033d947d19089a6b85.zip |
Try reloading model on class mismatch [#229 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/reload_models_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/test/cases/reload_models_test.rb b/activerecord/test/cases/reload_models_test.rb new file mode 100644 index 0000000000..411b5f6afa --- /dev/null +++ b/activerecord/test/cases/reload_models_test.rb @@ -0,0 +1,20 @@ +require "cases/helper" +require 'models/owner' +require 'models/pet' + +class ReloadModelsTest < ActiveRecord::TestCase + def test_has_one_with_reload + pet = Pet.find_by_name('parrot') + pet.owner = Owner.find_by_name('ashley') + + # Reload the class Owner, simulating auto-reloading of model classes in a + # development environment. Note that meanwhile the class Pet is not + # reloaded, simulating a class that is present in a plugin. + Object.class_eval { remove_const :Owner } + Kernel.load(File.expand_path(File.join(File.dirname(__FILE__), "../models/owner.rb"))) + + pet = Pet.find_by_name('parrot') + pet.owner = Owner.find_by_name('ashley') + assert_equal pet.owner, Owner.find_by_name('ashley') + end +end
\ No newline at end of file |