diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-05-08 17:39:02 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-05-09 22:26:55 +0200 |
commit | f4511690994f0c14c60320bbeecc66549332dbee (patch) | |
tree | d96262e1fe5de95b10b472929f916b2bf784c074 /activerecord/test/cases | |
parent | 28232ce99cea0d006de7b135efad2674e3f65c38 (diff) | |
download | rails-f4511690994f0c14c60320bbeecc66549332dbee.tar.gz rails-f4511690994f0c14c60320bbeecc66549332dbee.tar.bz2 rails-f4511690994f0c14c60320bbeecc66549332dbee.zip |
test, regression test for has_many with instance dependent scope.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 10 |
1 files changed, 10 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 2453d6cf58..5f01352ab4 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -1894,4 +1894,14 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_not pirate.valid?(:conference) assert_equal "can't be blank", ship.errors[:name].first end + + test 'association with instance dependent scope' do + bob = authors(:bob) + Post.create!(title: "signed post by bob", body: "stuff", author: authors(:bob)) + Post.create!(title: "anonymous post", body: "more stuff", author: authors(:bob)) + assert_equal ["misc post by bob", "other post by bob", + "signed post by bob"], bob.posts_with_signature.map(&:title).sort + + assert_equal [], authors(:david).posts_with_signature.map(&:title) + end end |