diff options
author | Andrew Horner <andrew@tablexi.com> | 2013-04-18 23:41:58 -0500 |
---|---|---|
committer | Andrew Horner <andrew@tablexi.com> | 2013-05-11 22:41:47 -0500 |
commit | c09829e03db611b46bb52e2054991222cf57bfbe (patch) | |
tree | 42c34f507693ff5e154272f830509a00b89a4462 /activerecord/test | |
parent | 5c6cf4e59e3e9c75395541162f2741b82347af0a (diff) | |
download | rails-c09829e03db611b46bb52e2054991222cf57bfbe.tar.gz rails-c09829e03db611b46bb52e2054991222cf57bfbe.tar.bz2 rails-c09829e03db611b46bb52e2054991222cf57bfbe.zip |
Preserve context for joins while merging relations
This is a backport of #10164, already merged into
master. The issue is described in lengthy detail
in issues #3002 and #5494.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 98fe6b7611..f14eee2eb8 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -4,6 +4,7 @@ require 'models/tagging' require 'models/post' require 'models/topic' require 'models/comment' +require 'models/rating' require 'models/reply' require 'models/author' require 'models/comment' @@ -19,7 +20,7 @@ require 'models/minivan' class RelationTest < ActiveRecord::TestCase fixtures :authors, :topics, :entrants, :developers, :companies, :developers_projects, :accounts, :categories, :categorizations, :posts, :comments, - :tags, :taggings, :cars, :minivans + :ratings, :tags, :taggings, :cars, :minivans def test_do_not_double_quote_string_id van = Minivan.last @@ -696,6 +697,12 @@ class RelationTest < ActiveRecord::TestCase assert_equal 1, comments.count end + def test_relation_merging_with_merged_joins + special_comments_with_ratings = SpecialComment.joins(:ratings) + posts_with_special_comments_with_ratings = Post.group('posts.id').joins(:special_comments).merge(special_comments_with_ratings) + assert_equal 1, authors(:david).posts.merge(posts_with_special_comments_with_ratings).count.length + end + def test_count posts = Post.scoped |