diff options
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 |