From 874603ce8d7b9077650ef3632a161597424486d9 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 30 Apr 2008 00:25:52 -0500 Subject: Change tests against all scope to base scope as all is now used as a finder alias --- activerecord/test/cases/named_scope_test.rb | 28 ++++++++++++++-------------- activerecord/test/models/reply.rb | 2 ++ activerecord/test/models/topic.rb | 1 + 3 files changed, 17 insertions(+), 14 deletions(-) (limited to 'activerecord') diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb index 3d3cecd603..e99448c23e 100644 --- a/activerecord/test/cases/named_scope_test.rb +++ b/activerecord/test/cases/named_scope_test.rb @@ -11,15 +11,15 @@ class NamedScopeTest < ActiveRecord::TestCase def test_implements_enumerable assert !Topic.find(:all).empty? - assert_equal Topic.find(:all), Topic.all - assert_equal Topic.find(:all), Topic.all.to_a - assert_equal Topic.find(:first), Topic.all.first - assert_equal Topic.find(:all), Topic.all.each { |i| i } + assert_equal Topic.find(:all), Topic.base + assert_equal Topic.find(:all), Topic.base.to_a + assert_equal Topic.find(:first), Topic.base.first + assert_equal Topic.find(:all), Topic.base.each { |i| i } end def test_found_items_are_cached Topic.columns - all_posts = Topic.all + all_posts = Topic.base assert_queries(1) do all_posts.collect @@ -28,7 +28,7 @@ class NamedScopeTest < ActiveRecord::TestCase end def test_reload_expires_cache_of_found_items - all_posts = Topic.all + all_posts = Topic.base all_posts.inspect new_post = Topic.create! @@ -39,17 +39,17 @@ class NamedScopeTest < ActiveRecord::TestCase def test_delegates_finds_and_calculations_to_the_base_class assert !Topic.find(:all).empty? - assert_equal Topic.find(:all), Topic.all.find(:all) - assert_equal Topic.find(:first), Topic.all.find(:first) - assert_equal Topic.count, Topic.all.count - assert_equal Topic.average(:replies_count), Topic.all.average(:replies_count) + assert_equal Topic.find(:all), Topic.base.find(:all) + assert_equal Topic.find(:first), Topic.base.find(:first) + assert_equal Topic.count, Topic.base.count + assert_equal Topic.average(:replies_count), Topic.base.average(:replies_count) end def test_subclasses_inherit_scopes - assert Topic.scopes.include?(:all) + assert Topic.scopes.include?(:base) - assert Reply.scopes.include?(:all) - assert_equal Reply.find(:all), Reply.all + assert Reply.scopes.include?(:base) + assert_equal Reply.find(:all), Reply.base end def test_scopes_with_options_limit_finds_to_those_matching_the_criteria_specified @@ -104,7 +104,7 @@ class NamedScopeTest < ActiveRecord::TestCase def test_active_records_have_scope_named__all__ assert !Topic.find(:all).empty? - assert_equal Topic.find(:all), Topic.all + assert_equal Topic.find(:all), Topic.base end def test_active_records_have_scope_named__scoped__ diff --git a/activerecord/test/models/reply.rb b/activerecord/test/models/reply.rb index 27621bd703..812bc1f535 100755 --- a/activerecord/test/models/reply.rb +++ b/activerecord/test/models/reply.rb @@ -1,6 +1,8 @@ require 'models/topic' class Reply < Topic + named_scope :base + belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true has_many :replies, :class_name => "SillyReply", :dependent => :destroy, :foreign_key => "parent_id" diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb index d2503b78df..f63e862cfd 100755 --- a/activerecord/test/models/topic.rb +++ b/activerecord/test/models/topic.rb @@ -1,4 +1,5 @@ class Topic < ActiveRecord::Base + named_scope :base named_scope :written_before, lambda { |time| { :conditions => ['written_on < ?', time] } } -- cgit v1.2.3