diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-17 17:16:24 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-17 17:16:24 +0000 |
commit | 0591c53efde948fd49a00aa23bdfc2ca26fca434 (patch) | |
tree | 452745f3ec56eb9a374b8f71eaf5448f64b833e8 /activerecord/test | |
parent | 806cf6d76ab557ceebf5ac5d22f3e39076e1ab61 (diff) | |
download | rails-0591c53efde948fd49a00aa23bdfc2ca26fca434.tar.gz rails-0591c53efde948fd49a00aa23bdfc2ca26fca434.tar.bz2 rails-0591c53efde948fd49a00aa23bdfc2ca26fca434.zip |
Made the dynamic finders use the new find API and updated the examples here and there
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1196 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/deprecated_finder_test.rb | 9 | ||||
-rw-r--r-- | activerecord/test/finder_test.rb | 15 |
2 files changed, 19 insertions, 5 deletions
diff --git a/activerecord/test/deprecated_finder_test.rb b/activerecord/test/deprecated_finder_test.rb index c9bf7c7f43..422e17747d 100755 --- a/activerecord/test/deprecated_finder_test.rb +++ b/activerecord/test/deprecated_finder_test.rb @@ -127,6 +127,15 @@ class FinderTest < Test::Unit::TestCase assert_equal 'fixture_9', last_two_developers.first.name end + def test_find_all_by_one_attribute_with_options + topics = Topic.find_all_by_content("Have a nice day", nil, "id DESC") + assert @topics["first"].find, topics.last + + topics = Topic.find_all_by_content("Have a nice day", nil, "id DESC") + assert @topics["first"].find, topics.first + end + + protected def bind(statement, *vars) if vars.first.is_a?(Hash) diff --git a/activerecord/test/finder_test.rb b/activerecord/test/finder_test.rb index dd8e8b5487..0c672c2e35 100644 --- a/activerecord/test/finder_test.rb +++ b/activerecord/test/finder_test.rb @@ -202,6 +202,14 @@ class FinderTest < Test::Unit::TestCase assert_equal [], Topic.find_all_by_title("The First Topic!!") end + + def test_find_all_by_one_attribute_with_options + topics = Topic.find_all_by_content("Have a nice day", :order => "id DESC") + assert @topics["first"].find, topics.last + + topics = Topic.find_all_by_content("Have a nice day", :order => "id") + assert @topics["first"].find, topics.first + end def test_find_all_by_boolean_attribute topics = Topic.find_all_by_approved(false) @@ -241,16 +249,13 @@ class FinderTest < Test::Unit::TestCase end def test_find_all_with_limit - first_five_developers = Developer.find_all nil, 'id ASC', 5 + first_five_developers = Developer.find :all, :order => 'id ASC', :limit => 5 assert_equal 5, first_five_developers.length assert_equal 'David', first_five_developers.first.name assert_equal 'fixture_5', first_five_developers.last.name - no_developers = Developer.find_all nil, 'id ASC', 0 + no_developers = Developer.find :all, :order => 'id ASC', :limit => 0 assert_equal 0, no_developers.length - - assert_equal first_five_developers, Developer.find_all(nil, 'id ASC', [5]) - assert_equal no_developers, Developer.find_all(nil, 'id ASC', [0]) end def test_find_all_with_limit_and_offset |