Permalink
Browse files

Return the correct status code when a NotFound is raised

  • Loading branch information...
1 parent 95aca76 commit eefc3d3b20c14ac992d598e5ef2bc4a66d495f2b @bleything bleything committed with rtomayko Dec 1, 2008
Showing with 16 additions and 1 deletion.
  1. +3 −0 ChangeLog
  2. +2 −1 lib/sinatra.rb
  3. +11 −0 test/application_test.rb
View
@@ -6,6 +6,9 @@
environment when given. Thin sets this when started with
the -e argument.
+ * BUG: raising Sinatra::NotFound resulted in a 500 response
+ code instead of 404.
+
* BUG: use_in_file_templates! failes with CR/LF (#45)
* BUG: Sinatra detects the app file and root path when run under
View
@@ -1271,7 +1271,8 @@ def dispatch(env)
request.env['rack.errors'] << msg
request.env['sinatra.error'] = e
- context.status(500)
+ status = e.class.code rescue 500
+ context.status(status)
raise if options.raise_errors && e.class != NotFound
result = (errors[e.class] || errors[ServerError]).invoke(request)
returned =
View
@@ -96,6 +96,17 @@ def each
end
+ specify "404 if NotFound is raised" do
+
+ get '/' do
+ raise Sinatra::NotFound
+ end
+
+ get_it '/'
+ should.be.not_found
+
+ end
+
end
context "Application#configure blocks" do

0 comments on commit eefc3d3

Please sign in to comment.