diff options
author | Subba Rao Pasupuleti <subbarao.pasupuleti@gmail.com> | 2010-07-19 21:26:57 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-07-21 15:01:40 +0200 |
commit | d77c3b669ce052234868b3d8e4f066e1baf9dbd5 (patch) | |
tree | 36d1b68df14a71860ed6133c12792f65c053f784 /activerecord/test/cases | |
parent | 992711a86bc4ddd4460f9067e49eea36b37ca94f (diff) | |
download | rails-d77c3b669ce052234868b3d8e4f066e1baf9dbd5.tar.gz rails-d77c3b669ce052234868b3d8e4f066e1baf9dbd5.tar.bz2 rails-d77c3b669ce052234868b3d8e4f066e1baf9dbd5.zip |
eagerly loaded association records should respect default_scope [#2931 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/relation_scoping_test.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb index a5a3b3ef38..fdf4536bc0 100644 --- a/activerecord/test/cases/relation_scoping_test.rb +++ b/activerecord/test/cases/relation_scoping_test.rb @@ -5,6 +5,8 @@ require 'models/developer' require 'models/project' require 'models/comment' require 'models/category' +require 'models/person' +require 'models/reference' class RelationScopingTest < ActiveRecord::TestCase fixtures :authors, :developers, :projects, :comments, :posts, :developers_projects @@ -218,7 +220,7 @@ class NestedRelationScopingTest < ActiveRecord::TestCase end class HasManyScopingTest< ActiveRecord::TestCase - fixtures :comments, :posts + fixtures :comments, :posts, :people, :references def setup @welcome = Post.find(1) @@ -250,6 +252,18 @@ class HasManyScopingTest< ActiveRecord::TestCase assert_equal 'a comment...', @welcome.comments.what_are_you end end + + def test_should_maintain_default_scope_on_associations + person = people(:michael) + magician = BadReference.find(1) + assert_equal [magician], people(:michael).bad_references + end + + def test_should_maintain_default_scope_on_eager_loaded_associations + michael = Person.where(:id => people(:michael).id).includes(:bad_references).first + magician = BadReference.find(1) + assert_equal [magician], michael.bad_references + end end class HasAndBelongsToManyScopingTest< ActiveRecord::TestCase @@ -399,4 +413,4 @@ class DefaultScopingTest < ActiveRecord::TestCase assert_equal nil, PoorDeveloperCalledJamis.create!(:salary => nil).salary assert_equal 50000, PoorDeveloperCalledJamis.create!(:name => 'David').salary end -end
\ No newline at end of file +end |