Merge pull request #805 from sbonami/fix-Request#accept-no_method_error

Fix Request#accept? NoMethodError
This commit is contained in:
Konstantin Haase 2013-11-01 12:28:07 -07:00
commit 257f49910d
2 changed files with 6 additions and 1 deletions

View File

@ -32,7 +32,7 @@ module Sinatra
end
def accept?(type)
preferred_type(type).include?(type)
preferred_type(type).to_s.include?(type)
end
def preferred_type(*types)

View File

@ -89,4 +89,9 @@ class RequestTest < Test::Unit::TestCase
assert request.accept?('text/html')
assert_equal '*/*', request.preferred_type.to_s
end
it 'will not accept types not specified in HTTP_ACCEPT when HTTP_ACCEPT is provided' do
request = Sinatra::Request.new 'HTTP_ACCEPT' => 'application/json'
assert !request.accept?('text/html')
end
end