Skip to content

Commit

Permalink
Make FlashHash#key? work with symbol and string
Browse files Browse the repository at this point in the history
Closes #17586
  • Loading branch information
Rafael Mendonça França committed Nov 11, 2014
1 parent fa58468 commit 5b259e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/middleware/flash.rb
Expand Up @@ -129,7 +129,7 @@ def keys
end

def key?(name)
@flashes.key? name
@flashes.key? name.to_s
end

def delete(key)
Expand Down
9 changes: 9 additions & 0 deletions actionpack/test/controller/flash_hash_test.rb
Expand Up @@ -29,6 +29,15 @@ def test_update
assert_equal 'world', @hash['hello']
end

def test_key
@hash['foo'] = 'bar'

assert @hash.key?('foo')
assert @hash.key?(:foo)
assert_not @hash.key?('bar')
assert_not @hash.key?(:bar)
end

def test_delete
@hash['foo'] = 'bar'
@hash.delete 'foo'
Expand Down

0 comments on commit 5b259e4

Please sign in to comment.