Skip to content
Browse files

test the case that only one association exist in references_many

  • Loading branch information...
1 parent 2ce191b commit 81d97cbfe69ae8f31b5a1c1834c757cfca417690 @flyerhzm committed Jan 24, 2011
Showing with 12 additions and 12 deletions.
  1. +12 −12 spec/mongoid-eager-loading/mongoid/criterion/eager_loading_spec.rb
View
24 spec/mongoid-eager-loading/mongoid/criterion/eager_loading_spec.rb
@@ -34,13 +34,13 @@
@post1 = @person1.posts.create(:title => "post1")
@post2 = @person1.posts.create(:title => "post2")
- @post3 = @person2.posts.create(:title => "post3")
+ @post3 = @person1.posts.create(:title => "post3")
@post4 = @person2.posts.create(:title => "post4")
@post5 = Post.create(:title => "post5")
@preference1 = @person1.preferences.create(:name => "preference1")
@preference2 = @person1.preferences.create(:name => "preference2")
- @preference3 = @person2.preferences.create(:name => "preference3")
+ @preference3 = @person1.preferences.create(:name => "preference3")
@preference4 = @person2.preferences.create(:name => "preference4")
@preference5 = Preference.create(:name => "preference5")
end
@@ -82,12 +82,12 @@
id_documents_map[@person3.id].should == [@person3]
id_associations_map = criteria.send(:id_associations_map)
- id_associations_map[@person1.id].should == [@post1, @post2]
- id_associations_map[@person2.id].should == [@post3, @post4]
+ id_associations_map[@person1.id].should == [@post1, @post2, @post3]
+ id_associations_map[@person2.id].should == [@post4]
id_associations_map[@person3.id].should == nil
- @person1.posts.should == [@post1, @post2]
- @person2.posts.should == [@post3, @post4]
+ @person1.posts.should == [@post1, @post2, @post3]
+ @person2.posts.should == [@post4]
@person3.posts.should == []
end
@@ -102,7 +102,7 @@
id_documents_map = criteria.send(:id_documents_map)
id_documents_map[@preference1.id].should == [@person1]
id_documents_map[@preference2.id].should == [@person1]
- id_documents_map[@preference3.id].should == [@person2]
+ id_documents_map[@preference3.id].should == [@person1]
id_documents_map[@preference4.id].should == [@person2]
id_documents_map[@preference5.id].should == nil
@@ -113,8 +113,8 @@
id_associations_map[@preference4.id].should == [@preference4]
id_associations_map[@preference5.id].should == nil
- @person1.preferences.should == [@preference1, @preference2]
- @person2.preferences.should == [@preference3, @preference4]
+ @person1.preferences.should == [@preference1, @preference2, @preference3]
+ @person2.preferences.should == [@preference4]
@person3.preferences.should == []
end
@@ -151,8 +151,8 @@
criteria.preload(posts)
id_documents_map = criteria.send(:id_documents_map)
- id_documents_map[@person1.id].should == [@post1, @post2]
- id_documents_map[@person2.id].should == [@post3, @post4]
+ id_documents_map[@person1.id].should == [@post1, @post2, @post3]
+ id_documents_map[@person2.id].should == [@post4]
id_documents_map[@person3.id].should == nil
id_associations_map = criteria.send(:id_associations_map)
@@ -162,7 +162,7 @@
@post1.person.should == @person1
@post2.person.should == @person1
- @post3.person.should == @person2
+ @post3.person.should == @person1
@post4.person.should == @person2
@post5.person.should == nil
end

0 comments on commit 81d97cb

Please sign in to comment.
Something went wrong with that request. Please try again.