aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/finder_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/finder_test.rb')
-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 543981b4a0..014588b6d9 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -74,6 +74,11 @@ class FinderTest < ActiveRecord::TestCase
end
end
+ def test_exists_does_not_instantiate_records
+ Developer.expects(:instantiate).never
+ Developer.exists?
+ end
+
def test_find_by_array_of_one_id
assert_kind_of(Array, Topic.find([ 1 ]))
assert_equal(1, Topic.find([ 1 ]).length)
@@ -203,6 +208,14 @@ class FinderTest < ActiveRecord::TestCase
end
end
+ def test_model_class_responds_to_first_bang
+ assert_equal topics(:first), Topic.order(:id).first!
+ assert_raises ActiveRecord::RecordNotFound do
+ Topic.delete_all
+ Topic.first!
+ end
+ end
+
def test_last_bang_present
assert_nothing_raised do
assert_equal topics(:second), Topic.where("title = 'The Second Topic of the day'").last!
@@ -215,6 +228,14 @@ class FinderTest < ActiveRecord::TestCase
end
end
+ def test_model_class_responds_to_last_bang
+ assert_equal topics(:fourth), Topic.last!
+ assert_raises ActiveRecord::RecordNotFound do
+ Topic.delete_all
+ Topic.last!
+ end
+ end
+
def test_unexisting_record_exception_handling
assert_raise(ActiveRecord::RecordNotFound) {
Topic.find(1).parent