5 class ReloadModelsTest
< ActiveRecord
::TestCase
8 def test_has_one_with_reload
9 pet
= Pet
.find_by_name('parrot')
10 pet
.owner
= Owner
.find_by_name('ashley')
12 # Reload the class Owner, simulating auto-reloading of model classes in a
13 # development environment. Note that meanwhile the class Pet is not
14 # reloaded, simulating a class that is present in a plugin.
15 Object
.class_eval
{ remove_const
:Owner }
16 Kernel
.load(File
.expand_path(File
.join(File
.dirname(__FILE__
), "../models/owner.rb")))
18 pet
= Pet
.find_by_name('parrot')
19 pet
.owner
= Owner
.find_by_name('ashley')
20 assert_equal pet
.owner
, Owner
.find_by_name('ashley')