1
0
Fork 0
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:
Simon Rozet 2009-04-17 15:22:22 +02:00 committed by Ryan Tomayko
parent ebceae7b1a
commit 87bf495b11
2 changed files with 13 additions and 0 deletions

View file

@ -959,6 +959,8 @@ module Sinatra
end
error NotFound do
content_type 'text/html'
(<<-HTML).gsub(/^ {8}/, '')
<!DOCTYPE html>
<html>

View file

@ -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/)