mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
449039a86d
Closes #7110 there's more work to do on rack-cache issue 69
54 lines
1.3 KiB
Ruby
54 lines
1.3 KiB
Ruby
require "isolation/abstract_unit"
|
|
require "active_support/log_subscriber/test_helper"
|
|
require "rack/test"
|
|
|
|
module ApplicationTests
|
|
module RackTests
|
|
class LoggerTest < ActiveSupport::TestCase
|
|
include ActiveSupport::Testing::Isolation
|
|
include ActiveSupport::LogSubscriber::TestHelper
|
|
include Rack::Test::Methods
|
|
|
|
def setup
|
|
build_app
|
|
require "#{app_path}/config/environment"
|
|
super
|
|
@logger = MockLogger.new
|
|
Rails.stubs(:logger).returns(@logger)
|
|
end
|
|
|
|
def teardown
|
|
super
|
|
teardown_app
|
|
end
|
|
|
|
def logs
|
|
@logs ||= @logger.logged(:info)
|
|
end
|
|
|
|
test "logger logs proper HTTP GET verb and path" do
|
|
get "/blah"
|
|
wait
|
|
assert_match(/^Started GET "\/blah"/, logs[0])
|
|
end
|
|
|
|
test "logger logs proper HTTP HEAD verb and path" do
|
|
head "/blah"
|
|
wait
|
|
assert_match(/^Started HEAD "\/blah"/, logs[0])
|
|
end
|
|
|
|
test "logger logs HTTP verb override" do
|
|
post "/", {:_method => 'put'}
|
|
wait
|
|
assert_match(/^Started PUT "\/"/, logs[0])
|
|
end
|
|
|
|
test "logger logs HEAD requests" do
|
|
post "/", {:_method => 'head'}
|
|
wait
|
|
assert_match(/^Started HEAD "\/"/, logs[0])
|
|
end
|
|
end
|
|
end
|
|
end
|