aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorBrian Christian <brchristian@gmail.com>2016-02-23 11:30:50 -0800
committerBrian Christian <brchristian@gmail.com>2016-02-27 11:10:19 -0800
commit761dc68d5708fe05eb5fc31ad7f2debdd321f4dd (patch)
tree4217a69db0daeb4bf9a7ef0eb88a4c63c7b94c2e /activerecord/test
parent048fd13ccdb9a314e54771cb17a0a5d56d0a8d3d (diff)
downloadrails-761dc68d5708fe05eb5fc31ad7f2debdd321f4dd.tar.gz
rails-761dc68d5708fe05eb5fc31ad7f2debdd321f4dd.tar.bz2
rails-761dc68d5708fe05eb5fc31ad7f2debdd321f4dd.zip
additional test assertions (limit and offset)
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/finder_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 09618a1d31..8be833b3b2 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -488,6 +488,14 @@ class FinderTest < ActiveRecord::TestCase
def test_second_to_last
assert_equal topics(:fourth).title, Topic.second_to_last.title
+
+ # test with offset
+ assert_equal topics(:fourth), Topic.offset(1).second_to_last
+ assert_equal nil, Topic.offset(5).second_to_last
+
+ #test with limit
+ assert_equal nil, Topic.limit(1).second
+ assert_equal nil, Topic.limit(1).second_to_last
end
def test_second_to_last_have_primary_key_order_by_default
@@ -506,6 +514,14 @@ class FinderTest < ActiveRecord::TestCase
def test_third_to_last
assert_equal topics(:third).title, Topic.third_to_last.title
+
+ # test with offset
+ assert_equal topics(:third), Topic.offset(1).third_to_last
+ assert_equal nil, Topic.offset(5).third_to_last
+
+ # test with limit
+ assert_equal nil, Topic.limit(1).third
+ assert_equal nil, Topic.limit(1).third_to_last
end
def test_third_to_last_have_primary_key_order_by_default