Skip to content

Commit

Permalink
Merge pull request #2134 from jstorimer/ensure-status-codes-are-logge…
Browse files Browse the repository at this point in the history
…d-properly-3-0-stable

Ensure status codes are logged properly (for 3-0-stable)
  • Loading branch information
spastorino committed Jul 18, 2011
2 parents 1220b16 + 5e64538 commit a6139b9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
10 changes: 5 additions & 5 deletions actionpack/lib/action_controller/base.rb
Expand Up @@ -204,16 +204,16 @@ def self.without_modules(*modules)
HttpAuthentication::Digest::ControllerMethods,
HttpAuthentication::Token::ControllerMethods,

# Add instrumentations hooks at the bottom, to ensure they instrument
# all the methods properly.
Instrumentation,

# Before callbacks should also be executed the earliest as possible, so
# also include them at the bottom.
AbstractController::Callbacks,

# The same with rescue, append it at the end to wrap as much as possible.
Rescue
Rescue,

# Add instrumentations hooks at the bottom, to ensure they instrument
# all the methods properly.
Instrumentation
]

MODULES.each do |mod|
Expand Down
22 changes: 21 additions & 1 deletion actionpack/test/controller/log_subscriber_test.rb
Expand Up @@ -4,6 +4,14 @@

module Another
class LogSubscribersController < ActionController::Base

class SpecialException < Exception
end

rescue_from SpecialException do
head :status => 406
end

def show
render :nothing => true
end
Expand Down Expand Up @@ -36,7 +44,11 @@ def with_page_cache
def with_exception
raise Exception
end


def with_rescued_exception
raise SpecialException
end

end
end

Expand Down Expand Up @@ -181,6 +193,14 @@ def test_process_action_with_exception_includes_http_status_code
assert_match(/Completed 500/, logs.last)
end

def test_process_action_with_rescued_exception_includes_http_status_code
get :with_rescued_exception
wait

assert_equal 2, logs.size
assert_match(/Completed 406/, logs.last)
end

def logs
@logs ||= @logger.logged(:info)
end
Expand Down

0 comments on commit a6139b9

Please sign in to comment.