Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe "Resource#initialize_path_to_self" do
- before :each do
- [ Person, Profile ].each { |model| model.auto_migrate! }
- end
- it "should return the root resource" do
- p = Profile.new(:nickname => 'snusnu')
- p.person = Person.new(:name => 'Martin')
- r = p.class.relationships[:person]
- p.initialize_path_to_self(r, p).should == p.person
- end
- it "should initialize the inverse relationship" do
- Profile.all.size.should == 0
- Person.all.size.should == 0
- p = Profile.new(:nickname => 'snusnu')
- p.person = Person.new(:name => 'Martin')
- r = p.class.relationships[:person]
- p.person.profile.should be_nil
- p.initialize_path_to_self(r, p)
- p.person.profile.should == p
- p.person.save.should be_true
- Person.all.size.should == 1
- Profile.all.size.should == 1
- end
- end
Add Comment
Please, Sign In to add comment