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