Skip to content

Commit

Permalink
Merge pull request #993 from ujifgc/master
Browse files Browse the repository at this point in the history
Fixing #818
  • Loading branch information
nesquena committed Jan 10, 2013
2 parents 32c9349 + 560c949 commit 4f2afd7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion padrino-core/lib/padrino-core/application/routing.rb
Expand Up @@ -907,9 +907,11 @@ def filter!(type, base=settings)
def dispatch!
static! if settings.static? && (request.get? || request.head?)
route!
rescue ::Exception => boom
rescue ::Sinatra::NotFound => boom
filter! :before
handle_exception!(boom)
rescue ::Exception => boom
handle_exception!(boom)
ensure
filter! :after unless env['sinatra.static_file']
end
Expand Down
19 changes: 19 additions & 0 deletions padrino-core/test/test_filters.rb
Expand Up @@ -275,4 +275,23 @@
get '/foo'
assert_equal 'before', test
end

should "call before filters only once" do
once = ''
mock_app do
error 500 do
'error 500'
end
before do
once += 'before'
end
get :index do
raise Exception, 'Oops'
end
end

get '/'
assert_equal 'before', once
end

end

0 comments on commit 4f2afd7

Please sign in to comment.