Guest User

Untitled

a guest
Jun 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. describe "Resource#initialize_path_to_self" do
  2.  
  3. before :each do
  4. [ Person, Profile ].each { |model| model.auto_migrate! }
  5. end
  6.  
  7. it "should return the root resource" do
  8. p = Profile.new(:nickname => 'snusnu')
  9. p.person = Person.new(:name => 'Martin')
  10. r = p.class.relationships[:person]
  11. p.initialize_path_to_self(r, p).should == p.person
  12. end
  13.  
  14. it "should initialize the inverse relationship" do
  15. Profile.all.size.should == 0
  16. Person.all.size.should == 0
  17.  
  18. p = Profile.new(:nickname => 'snusnu')
  19. p.person = Person.new(:name => 'Martin')
  20. r = p.class.relationships[:person]
  21. p.person.profile.should be_nil
  22. p.initialize_path_to_self(r, p)
  23. p.person.profile.should == p
  24.  
  25. p.person.save.should be_true
  26.  
  27. Person.all.size.should == 1
  28. Profile.all.size.should == 1
  29. end
  30.  
  31. end
Add Comment
Please, Sign In to add comment