diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-08-20 13:38:06 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-08-20 13:38:06 -0300 |
commit | 79bcab79d97239593c8f9500c70226abada341c6 (patch) | |
tree | 3c1aec608cd521e19e183ccf5147d19dda54b3ab /activerecord/test/cases/relation | |
parent | b66bb42dc172716d29fb33c97799f1786af3ce9f (diff) | |
parent | 431f8e01196044877c2acea4271410b1033ec915 (diff) | |
download | rails-79bcab79d97239593c8f9500c70226abada341c6.tar.gz rails-79bcab79d97239593c8f9500c70226abada341c6.tar.bz2 rails-79bcab79d97239593c8f9500c70226abada341c6.zip |
Merge pull request #16172 from Agis-/hmt_scope_arity
has_many :through with dynamic condition merging
Diffstat (limited to 'activerecord/test/cases/relation')
-rw-r--r-- | activerecord/test/cases/relation/merging_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/relation/merging_test.rb b/activerecord/test/cases/relation/merging_test.rb index 2b5c2fd5a4..54a581e416 100644 --- a/activerecord/test/cases/relation/merging_test.rb +++ b/activerecord/test/cases/relation/merging_test.rb @@ -4,6 +4,7 @@ require 'models/comment' require 'models/developer' require 'models/post' require 'models/project' +require 'models/rating' class RelationMergingTest < ActiveRecord::TestCase fixtures :developers, :comments, :authors, :posts @@ -144,4 +145,16 @@ class MergingDifferentRelationsTest < ActiveRecord::TestCase assert_equal ["Mary", "Mary", "Mary", "David"], posts_by_author_name end + + test "relation merging (using a proc argument)" do + dev = Developer.where(name: "Jamis").first + + comment_1 = dev.comments.create!(body: "I'm Jamis", post: Post.first) + rating_1 = comment_1.ratings.create! + + comment_2 = dev.comments.create!(body: "I'm John", post: Post.first) + rating_2 = comment_2.ratings.create! + + assert_equal dev.ratings, [rating_1] + end end |