mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Ensure development NotFound handler always returns text/html
This commit is contained in:
parent
ebceae7b1a
commit
87bf495b11
2 changed files with 13 additions and 0 deletions
|
@ -959,6 +959,8 @@ module Sinatra
|
|||
end
|
||||
|
||||
error NotFound do
|
||||
content_type 'text/html'
|
||||
|
||||
(<<-HTML).gsub(/^ {8}/, '')
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
|
|
@ -44,6 +44,17 @@ class RoutingTest < Test::Unit::TestCase
|
|||
assert_equal 404, status
|
||||
end
|
||||
|
||||
test "development NotFound handler" do
|
||||
mock_app {
|
||||
before { content_type 'text/plain' }
|
||||
}
|
||||
|
||||
get '/foo'
|
||||
assert_equal 404, status
|
||||
assert_equal 'text/html', response["Content-Type"]
|
||||
assert body.include?("Sinatra doesn't know this ditty")
|
||||
end
|
||||
|
||||
it 'takes multiple definitions of a route' do
|
||||
mock_app {
|
||||
user_agent(/Foo/)
|
||||
|
|
Loading…
Reference in a new issue