From 141d864e0ec1098176141e6cb6aef3eaf07e830f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 29 Aug 2014 14:58:36 -0700 Subject: Added yield to Object#presence --- activesupport/test/core_ext/object/blank_test.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activesupport/test') diff --git a/activesupport/test/core_ext/object/blank_test.rb b/activesupport/test/core_ext/object/blank_test.rb index 246bc7fa61..7b3f10b4da 100644 --- a/activesupport/test/core_ext/object/blank_test.rb +++ b/activesupport/test/core_ext/object/blank_test.rb @@ -33,4 +33,9 @@ class BlankTest < ActiveSupport::TestCase BLANK.each { |v| assert_equal nil, v.presence, "#{v.inspect}.presence should return nil" } NOT.each { |v| assert_equal v, v.presence, "#{v.inspect}.presence should return self" } end + + def test_presence_with_a_block + assert_equal "SALLY", "sally".presence(&:upcase) || "Nobody" + assert_equal "Nobody", nil.presence(&:upcase) || "Nobody" + end end -- cgit v1.2.3