diff options
author | Jared Armstrong <jared.armstrong@gmail.com> | 2012-03-17 00:37:56 +1300 |
---|---|---|
committer | Jared Armstrong <jared.armstrong@gmail.com> | 2012-05-04 22:57:01 +1200 |
commit | 0d8cf53296a4d7c1e6d85c533784a2607bfe3baa (patch) | |
tree | a90db9c03a9617c940ab8221f9566100d737a083 /activerecord/test | |
parent | 5f62c86b50f21ef14ffda1112a8cd002e87590ca (diff) | |
download | rails-0d8cf53296a4d7c1e6d85c533784a2607bfe3baa.tar.gz rails-0d8cf53296a4d7c1e6d85c533784a2607bfe3baa.tar.bz2 rails-0d8cf53296a4d7c1e6d85c533784a2607bfe3baa.zip |
Allow ActiveRecord::Relation merges to maintain context of joined associations
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 3ef357e297..48fc82bbc7 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -6,6 +6,7 @@ require 'models/topic' require 'models/comment' require 'models/author' require 'models/comment' +require 'models/rating' require 'models/entrant' require 'models/developer' require 'models/reply' @@ -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 @@ -731,6 +732,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).to_a.length + end + def test_count posts = Post.scoped |