diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2014-08-29 14:58:36 -0700 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2014-08-29 14:58:36 -0700 |
commit | 141d864e0ec1098176141e6cb6aef3eaf07e830f (patch) | |
tree | 230f6a02b842585c354df231d03fee6975d7dca7 /activesupport/test/core_ext/object | |
parent | 7475b43cdbbbf7456e798210cb97ef20f2225166 (diff) | |
download | rails-141d864e0ec1098176141e6cb6aef3eaf07e830f.tar.gz rails-141d864e0ec1098176141e6cb6aef3eaf07e830f.tar.bz2 rails-141d864e0ec1098176141e6cb6aef3eaf07e830f.zip |
Added yield to Object#presence
Diffstat (limited to 'activesupport/test/core_ext/object')
-rw-r--r-- | activesupport/test/core_ext/object/blank_test.rb | 5 |
1 files changed, 5 insertions, 0 deletions
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 |