diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-04-30 15:55:50 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-04-30 16:14:15 -0700 |
commit | de6a067078ade6d4c9775ebd9d05ebb94b3a6b54 (patch) | |
tree | 3e4ccf64a99ca7e0630e514dbdf27cac8b3eb0f9 /activerecord/test | |
parent | f0182d5cb9755e2a8ef933ea6b93d5e42f6d367d (diff) | |
download | rails-de6a067078ade6d4c9775ebd9d05ebb94b3a6b54.tar.gz rails-de6a067078ade6d4c9775ebd9d05ebb94b3a6b54.tar.bz2 rails-de6a067078ade6d4c9775ebd9d05ebb94b3a6b54.zip |
return value of block is returned
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 02d5320d9d..da4dfb4b33 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -180,9 +180,17 @@ class BasicsTest < ActiveRecord::TestCase found = nil Topic.find_by_id(t.id) { |f| found = f } assert_equal t, found + end + def test_finder_block_nothing_found bad_id = Topic.maximum(:id) + 1 - Topic.find_by_id(bad_id) { |f| raise } + assert_nil Topic.find_by_id(bad_id) { |f| raise } + end + + def test_find_returns_block_value + t = Topic.first + x = Topic.find_by_id(t.id) { |f| "hi mom!" } + assert_equal "hi mom!", x end def test_preserving_date_objects |