Permalink
Browse files

add test for fetch with a block

  • Loading branch information...
1 parent 6ea781c commit b2debfb005cc6d0661b24c50983a885509f7f9c9 @tenderlove tenderlove committed Oct 18, 2012
Showing with 6 additions and 2 deletions.
  1. +2 −2 actionpack/lib/action_dispatch/http/headers.rb
  2. +4 −0 actionpack/test/dispatch/header_test.rb
@@ -17,8 +17,8 @@ def []=(k,v); @headers[k] = v; end
def key?(k); @headers.key? k; end
alias :include? :key?
- def fetch(header_name, default=nil, &block)
- @headers.fetch env_name(header_name), default, &block
+ def fetch(header_name, *args, &block)
+ @headers.fetch env_name(header_name), *args, &block
end
def each(&block)
@@ -23,6 +23,10 @@ def test_key?
assert @headers.include?('HTTP_CONTENT_TYPE')
end
+ def test_fetch_with_block
+ assert_equal 'omg', @headers.fetch('notthere') { 'omg' }
+ end
+
test "content type" do
assert_equal "text/plain", @headers["Content-Type"]
assert_equal "text/plain", @headers["content-type"]

0 comments on commit b2debfb

Please sign in to comment.