diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-24 19:59:22 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-24 19:59:22 +0000 |
commit | c6f2af5c31577e25c6f6b9f17be18858200a8e13 (patch) | |
tree | 4b5835b922381231aca10b5b1235d4a555a3af83 /activerecord/test | |
parent | 081ddb6f24d70794ee9e071d3ed5302f52b26c4d (diff) | |
download | rails-c6f2af5c31577e25c6f6b9f17be18858200a8e13.tar.gz rails-c6f2af5c31577e25c6f6b9f17be18858200a8e13.tar.bz2 rails-c6f2af5c31577e25c6f6b9f17be18858200a8e13.zip |
Added ActiveRecord#Base.all/first/last as aliases for find(:all/:first/:last) (closes #11413) [nkallen, thechrisoshow]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9085 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/cases/base_test.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index d8b107177f..025858bf15 100755 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1625,6 +1625,10 @@ class BasicsTest < ActiveRecord::TestCase assert_equal last, Developer.find(:first, :order => 'id desc') end + def test_last + assert_equal Developer.find(:first, :order => 'id desc'), Developer.last + end + def test_find_ordered_last last = Developer.find :last, :order => 'developers.salary ASC' assert_equal last, Developer.find(:all, :order => 'developers.salary ASC').last diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index 5da8603070..8cb5c9206a 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -143,6 +143,14 @@ class FinderTest < ActiveRecord::TestCase first = Topic.find(:first, :conditions => "title = 'The First Topic!'") assert_nil(first) end + + def test_first + assert_equal topics(:second).title, Topic.first(:conditions => "title = 'The Second Topic of the day'").title + end + + def test_first_failing + assert_nil Topic.first(:conditions => "title = 'The Second Topic of the day!'") + end def test_unexisting_record_exception_handling assert_raises(ActiveRecord::RecordNotFound) { |