aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/finder_test.rb
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2015-12-18 15:54:04 +1030
committerMatthew Draper <matthew@trebex.net>2015-12-18 15:54:04 +1030
commit04309aee82468fa4c4b3d92a533e84a96533f236 (patch)
tree4381dd87ac4d9b465d6fc18d812176889c2aceb4 /activerecord/test/cases/finder_test.rb
parenteaefe87c5ed33b9581906a4848163a6c32a1ee24 (diff)
downloadrails-04309aee82468fa4c4b3d92a533e84a96533f236.tar.gz
rails-04309aee82468fa4c4b3d92a533e84a96533f236.tar.bz2
rails-04309aee82468fa4c4b3d92a533e84a96533f236.zip
Implement limit & offset for ourselves
We know the query will return exactly one row for each entry in the `ids` array, so we can do all the limit/offset calculations on that array, in advance. I also split our new ordered-ids behaviour out of the existing `find_some` method: especially with this change, the conditionals were overwhelming the actual logic.
Diffstat (limited to 'activerecord/test/cases/finder_test.rb')
-rw-r--r--activerecord/test/cases/finder_test.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 47059fe9e4..3c3f3284ac 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -109,7 +109,7 @@ class FinderTest < ActiveRecord::TestCase
assert_equal 'The Fifth Topic of the day', records[2].title
end
- def test_find_with_ids_and_offset # failing with offset
+ def test_find_with_ids_and_offset
records = Topic.offset(2).find([3,2,5,1,4])
assert_equal 3, records.size
assert_equal 'The Fifth Topic of the day', records[0].title
@@ -261,7 +261,7 @@ class FinderTest < ActiveRecord::TestCase
assert_equal topics(:second).title, Topic.find([2]).first.title
end
- def test_find_by_ids_with_limit_and_offset # failing with offset
+ def test_find_by_ids_with_limit_and_offset
assert_equal 2, Entrant.limit(2).find([1,3,2]).size
entrants = Entrant.limit(3).offset(2).find([1,3,2])
assert_equal 1, entrants.size