aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/finder_test.rb
diff options
context:
space:
mode:
authorDamien Mathieu <42@dmathieu.com>2011-09-01 11:24:19 +0200
committerDamien Mathieu <42@dmathieu.com>2011-09-05 13:09:52 +0200
commit451cdd62ce54080d0a4944551fbc3f10cc34a42d (patch)
treefd5c5b14c76a5aab88ee7081bcb363134b9e9cd4 /activerecord/test/cases/finder_test.rb
parent24ee573d6ce8bb11f7eb62224feca5a87fdd2a69 (diff)
downloadrails-451cdd62ce54080d0a4944551fbc3f10cc34a42d.tar.gz
rails-451cdd62ce54080d0a4944551fbc3f10cc34a42d.tar.bz2
rails-451cdd62ce54080d0a4944551fbc3f10cc34a42d.zip
use LIMIT SQL word in first - Closes #2783
Diffstat (limited to 'activerecord/test/cases/finder_test.rb')
-rw-r--r--activerecord/test/cases/finder_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 5dc5f99582..fbcae27719 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -243,6 +243,15 @@ class FinderTest < ActiveRecord::TestCase
end
end
+ def test_first_with_integer_should_use_sql_limit
+ assert_sql(/LIMIT 2/) { Topic.first(2).entries }
+ end
+
+ def test_first_and_last_with_integer_should_return_an_array
+ assert_kind_of Array, Topic.first(5)
+ assert_kind_of Array, Topic.last(5)
+ end
+
def test_unexisting_record_exception_handling
assert_raise(ActiveRecord::RecordNotFound) {
Topic.find(1).parent