aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb4
-rw-r--r--activerecord/test/models/post.rb1
2 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index cd19a7a5bc..4ecf53e6d1 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -2358,4 +2358,8 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal [bulb.id], car.bulb_ids
assert_no_queries { car.bulb_ids }
end
+
+ def test_has_many_association_with_rewhere
+ assert_equal 'Don\'t think too hard', posts(:welcome).comments_with_rewhere.first.body
+ end
end
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index 81a18188d4..45a379df98 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -67,6 +67,7 @@ class Post < ActiveRecord::Base
end
has_many :comments_with_extend_2, extend: [NamedExtension, NamedExtension2], class_name: "Comment", foreign_key: "post_id"
+ has_many :comments_with_rewhere, -> { rewhere(post_id: 2) }, class_name: "Comment"
has_many :author_favorites, :through => :author
has_many :author_categorizations, :through => :author, :source => :categorizations