diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-04-10 09:24:37 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-04-10 09:24:37 -0700 |
commit | 8c883855b40d4ecfb52329ab2de72755be6ad1ba (patch) | |
tree | 67a973f866c2371bbb07ee2457ed992d08d46de7 /activerecord/test | |
parent | d716fe05dfc174af4d840258b52e690ff754c8c3 (diff) | |
parent | dc764fcc348d562376add26ff8ef5173946b575b (diff) | |
download | rails-8c883855b40d4ecfb52329ab2de72755be6ad1ba.tar.gz rails-8c883855b40d4ecfb52329ab2de72755be6ad1ba.tar.bz2 rails-8c883855b40d4ecfb52329ab2de72755be6ad1ba.zip |
Merge pull request #10164 from neerajdotname/3002-final
While merging relations preserve context for joins
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relation_test.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb index 9ca980fdf6..1967d8716a 100644 --- a/activerecord/test/cases/relation_test.rb +++ b/activerecord/test/cases/relation_test.rb @@ -1,10 +1,12 @@ require "cases/helper" require 'models/post' require 'models/comment' +require 'models/author' +require 'models/rating' module ActiveRecord class RelationTest < ActiveRecord::TestCase - fixtures :posts, :comments + fixtures :posts, :comments, :authors class FakeKlass < Struct.new(:table_name, :name) end @@ -176,6 +178,13 @@ module ActiveRecord relation.merge!(where: ['foo = ?', 'bar']) assert_equal ['foo = bar'], relation.where_values 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 3, authors(:david).posts.merge(posts_with_special_comments_with_ratings).to_a.length + end + end class RelationMutationTest < ActiveSupport::TestCase |