diff options
author | James Yang <jamesyang124@gmail.com> | 2014-06-09 01:18:43 -0700 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-06-10 08:46:07 +0200 |
commit | 9feb4a8b5c4c9834986c7451bac078b37ed554b2 (patch) | |
tree | 1f8883f406a75d099acca4b3fc525aaaa4a9de41 /activerecord/test | |
parent | 8ed1dec25e8a818edca1fec3f064b9937326836c (diff) | |
download | rails-9feb4a8b5c4c9834986c7451bac078b37ed554b2.tar.gz rails-9feb4a8b5c4c9834986c7451bac078b37ed554b2.tar.bz2 rails-9feb4a8b5c4c9834986c7451bac078b37ed554b2.zip |
ActiveRecord::FinderMethods.find passes proc parameter #15382
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index c0440744e9..0f52f2c0fc 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -33,6 +33,17 @@ class FinderTest < ActiveRecord::TestCase assert_equal(topics(:first).title, Topic.find(1).title) end + def test_find_with_proc_parameter_and_block + e = assert_raises(RuntimeError) do + Topic.all.find(-> { raise "should happen" }) { |e| e.title == "non-existing-title" } + end + assert_equal "should happen", e.message + + assert_nothing_raised(RuntimeError) do + Topic.all.find(-> { raise "should not happen" }) { |e| e.title == topics(:first).title } + end + end + def test_find_passing_active_record_object_is_deprecated assert_deprecated do Topic.find(Topic.last) |