aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/base_test.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-04-30 15:51:09 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2012-04-30 16:14:15 -0700
commitf0182d5cb9755e2a8ef933ea6b93d5e42f6d367d (patch)
tree3979b48ecc211437f7924c4ee091391c5c5e50f5 /activerecord/test/cases/base_test.rb
parent838101ae04be06138f1bd7418473092b92754293 (diff)
downloadrails-f0182d5cb9755e2a8ef933ea6b93d5e42f6d367d.tar.gz
rails-f0182d5cb9755e2a8ef933ea6b93d5e42f6d367d.tar.bz2
rails-f0182d5cb9755e2a8ef933ea6b93d5e42f6d367d.zip
only yield to finder block if something is found
Diffstat (limited to 'activerecord/test/cases/base_test.rb')
-rw-r--r--activerecord/test/cases/base_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 8a4ce5e963..02d5320d9d 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -175,6 +175,16 @@ class BasicsTest < ActiveRecord::TestCase
assert Topic.table_exists?
end
+ def test_finder_block
+ t = Topic.first
+ found = nil
+ Topic.find_by_id(t.id) { |f| found = f }
+ assert_equal t, found
+
+ bad_id = Topic.maximum(:id) + 1
+ Topic.find_by_id(bad_id) { |f| raise }
+ end
+
def test_preserving_date_objects
if current_adapter?(:SybaseAdapter)
# Sybase ctlib does not (yet?) support the date type; use datetime instead.