aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-05-08 23:43:34 +0100
committerJon Leighton <j@jonathanleighton.com>2011-05-08 23:43:34 +0100
commit72a489345280964b4e4350fa6104658cd4e8da84 (patch)
tree8351dd83c3f7254c6ff0ed9f2c7a3eac832d2323 /activerecord/test
parent8f10ccd311e0813114c1aca266c82651ae77f6ca (diff)
parent92c10760d7f5e1d308e492d5fd3d551df41bfabb (diff)
downloadrails-72a489345280964b4e4350fa6104658cd4e8da84.tar.gz
rails-72a489345280964b4e4350fa6104658cd4e8da84.tar.bz2
rails-72a489345280964b4e4350fa6104658cd4e8da84.zip
Merge pull request #451 from baroquebobcat/fixing_last_for_issue_371
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/finder_test.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index be4ba18555..4e75eafe3d 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -683,6 +683,27 @@ class FinderTest < ActiveRecord::TestCase
assert_nil Topic.find_last_by_title_and_author_name(topic.title, "Anonymous")
end
+ def test_find_last_with_limit_gives_same_result_when_loaded_and_unloaded
+ scope = Topic.limit(2)
+ unloaded_last = scope.last
+ loaded_last = scope.all.last
+ assert_equal loaded_last, unloaded_last
+ end
+
+ def test_find_last_with_limit_and_offset_gives_same_result_when_loaded_and_unloaded
+ scope = Topic.offset(2).limit(2)
+ unloaded_last = scope.last
+ loaded_last = scope.all.last
+ assert_equal loaded_last, unloaded_last
+ end
+
+ def test_find_last_with_offset_gives_same_result_when_loaded_and_unloaded
+ scope = Topic.offset(3)
+ unloaded_last = scope.last
+ loaded_last = scope.all.last
+ assert_equal loaded_last, unloaded_last
+ end
+
def test_find_all_by_one_attribute
topics = Topic.find_all_by_content("Have a nice day")
assert_equal 2, topics.size