diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-18 04:24:24 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-18 04:24:24 +0530 |
commit | 88de6b2de2606e141483ff90323c5f3ec0cfb298 (patch) | |
tree | d29af6f939afa75801753fa42307b5f0589d7b57 /activerecord/test/cases | |
parent | c6850d8361bbf288cf3adefd087cb9a4bc9c97bc (diff) | |
download | rails-88de6b2de2606e141483ff90323c5f3ec0cfb298.tar.gz rails-88de6b2de2606e141483ff90323c5f3ec0cfb298.tar.bz2 rails-88de6b2de2606e141483ff90323c5f3ec0cfb298.zip |
Inherit named scope class Scope from Relation
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/named_scope_test.rb | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb index 09a657791e..ce1ac845cd 100644 --- a/activerecord/test/cases/named_scope_test.rb +++ b/activerecord/test/cases/named_scope_test.rb @@ -31,7 +31,7 @@ class NamedScopeTest < ActiveRecord::TestCase def test_reload_expires_cache_of_found_items all_posts = Topic.base - all_posts.inspect + all_posts.all new_post = Topic.create! assert !all_posts.include?(new_post) @@ -48,14 +48,14 @@ class NamedScopeTest < ActiveRecord::TestCase end def test_scope_should_respond_to_own_methods_and_methods_of_the_proxy - assert Topic.approved.respond_to?(:proxy_found) + assert Topic.approved.respond_to?(:limit) assert Topic.approved.respond_to?(:count) assert Topic.approved.respond_to?(:length) end def test_respond_to_respects_include_private_parameter - assert !Topic.approved.respond_to?(:load_found) - assert Topic.approved.respond_to?(:load_found, true) + assert !Topic.approved.respond_to?(:with_create_scope) + assert Topic.approved.respond_to?(:with_create_scope, true) end def test_subclasses_inherit_scopes @@ -155,7 +155,7 @@ class NamedScopeTest < ActiveRecord::TestCase assert_not_equal Post.ranked_by_comments.limit_by(5), authors(:david).posts.ranked_by_comments.limit_by(5) assert_not_equal Post.top(5), authors(:david).posts.top(5) # Oracle sometimes sorts differently if WHERE condition is changed - assert_equal authors(:david).posts.ranked_by_comments.limit_by(5).sort_by(&:id), authors(:david).posts.top(5).sort_by(&:id) + assert_equal authors(:david).posts.ranked_by_comments.limit_by(5).to_a.sort_by(&:id), authors(:david).posts.top(5).to_a.sort_by(&:id) assert_equal Post.ranked_by_comments.limit_by(5), Post.top(5) end @@ -171,11 +171,6 @@ class NamedScopeTest < ActiveRecord::TestCase assert_equal Topic.find(:all, scope), Topic.scoped(scope) end - def test_proxy_options - expected_proxy_options = { :conditions => { :approved => true } } - assert_equal expected_proxy_options, Topic.approved.proxy_options - end - def test_first_and_last_should_support_find_options assert_equal Topic.base.first(:order => 'title'), Topic.base.find(:first, :order => 'title') assert_equal Topic.base.last(:order => 'title'), Topic.base.find(:last, :order => 'title') @@ -297,7 +292,7 @@ class NamedScopeTest < ActiveRecord::TestCase end def test_find_all_should_behave_like_select - assert_equal Topic.base.select(&:approved), Topic.base.find_all(&:approved) + assert_equal Topic.base.to_a.select(&:approved), Topic.base.to_a.find_all(&:approved) end def test_rand_should_select_a_random_object_from_proxy |