Merge pull request #805 from sbonami/fix-Request#accept-no_method_error
Fix Request#accept? NoMethodError
This commit is contained in:
commit
257f49910d
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue