spec/join_association_spec.rb in arel-helpers-2.0.0 vs spec/join_association_spec.rb in arel-helpers-2.0.1
- old
+ new
@@ -24,10 +24,10 @@
it "should work for two models, one directly associated and the other indirectly" do
Post
.joins(ArelHelpers.join_association(Post, :comments))
.joins(ArelHelpers.join_association(Comment, :author))
.to_sql.should ==
- 'SELECT "posts".* FROM "posts" INNER JOIN "comments" ON "comments"."post_id" = "posts"."id" INNER JOIN "authors" ON "authors"."comment_id" = "comments"."id"'
+ 'SELECT "posts".* FROM "posts" INNER JOIN "comments" ON "comments"."post_id" = "posts"."id" INNER JOIN "authors" ON "authors"."id" = "comments"."author_id"'
end
it "should be able to handle multiple associations" do
Post.joins(ArelHelpers.join_association(Post, [:comments, :favorites])).to_sql.should ==
'SELECT "posts".* FROM "posts" INNER JOIN "comments" ON "comments"."post_id" = "posts"."id" INNER JOIN "favorites" ON "favorites"."post_id" = "posts"."id"'