diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-04-30 15:51:09 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-04-30 16:14:15 -0700 |
commit | f0182d5cb9755e2a8ef933ea6b93d5e42f6d367d (patch) | |
tree | 3979b48ecc211437f7924c4ee091391c5c5e50f5 /activerecord/test | |
parent | 838101ae04be06138f1bd7418473092b92754293 (diff) | |
download | rails-f0182d5cb9755e2a8ef933ea6b93d5e42f6d367d.tar.gz rails-f0182d5cb9755e2a8ef933ea6b93d5e42f6d367d.tar.bz2 rails-f0182d5cb9755e2a8ef933ea6b93d5e42f6d367d.zip |
only yield to finder block if something is found
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 10 |
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. |