aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMiguel Grazziotin <miguelgraz@gmail.com>2015-08-07 17:11:10 -0300
committerMiguel Grazziotin <miguelgraz@gmail.com>2015-08-07 17:11:10 -0300
commiteaefe87c5ed33b9581906a4848163a6c32a1ee24 (patch)
tree811f974b7bd1f21de5b5ace629d7293f6e8faa60 /activerecord
parentd3b8216fda928cf26c953dfd51a9a8d7f4732608 (diff)
downloadrails-eaefe87c5ed33b9581906a4848163a6c32a1ee24.tar.gz
rails-eaefe87c5ed33b9581906a4848163a6c32a1ee24.tar.bz2
rails-eaefe87c5ed33b9581906a4848163a6c32a1ee24.zip
Adding a new test using chained where, limit and find([pks])
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/finder_test.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 526623ec36..47059fe9e4 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -99,7 +99,17 @@ class FinderTest < ActiveRecord::TestCase
assert_equal 'The Fifth Topic of the day', records[2].title
end
- def test_find_with_ids_and_offset
+ def test_find_with_ids_where_and_limit
+ # Please note that Topic 1 is the only not approved so
+ # if it were among the first 3 it would raise a ActiveRecord::RecordNotFound
+ records = Topic.where(approved: true).limit(3).find([3,2,5,1,4])
+ assert_equal 3, records.size
+ assert_equal 'The Third Topic of the day', records[0].title
+ assert_equal 'The Second Topic of the day', records[1].title
+ assert_equal 'The Fifth Topic of the day', records[2].title
+ end
+
+ def test_find_with_ids_and_offset # failing with 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
@@ -251,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
+ def test_find_by_ids_with_limit_and_offset # failing with 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