Add pending specs for log_overrider... hit a wall when I wanted more information than is being passed to ActiveSupport::Notifier
This commit is contained in:
parent
d8bc610adb
commit
eccc25e20a
2 changed files with 43 additions and 4 deletions
|
|
@ -4,6 +4,7 @@ class ActionView::LogSubscriber
|
|||
message << "template=#{from_rails_root(event.payload[:identifier])} "
|
||||
message << "layout=#{from_rails_root(event.payload[:layout])} " if event.payload[:layout]
|
||||
message << "ms=#{("%.1f" % event.duration)} "
|
||||
#message << "r_id=#{event.transaction_id} "
|
||||
Rails.logger.info(message)
|
||||
end
|
||||
alias :render_partial :render_template
|
||||
|
|
@ -24,7 +25,8 @@ class ActionController::LogSubscriber
|
|||
log_string << "controller=#{payload[:controller]} action=#{payload[:action]} format=#{payload[:formats].first.to_s.upcase} "
|
||||
log_string << "ms=#{"%.0f" % event.duration} "
|
||||
log_string << "params='#{params.inspect}' " unless params.empty?
|
||||
log_string << "additions='#{additions.join(" | ")}'" unless additions.blank?
|
||||
#log_string << "additions='#{additions.join(" | ")}' " unless additions.blank?
|
||||
log_string << "r_id=#{event.transaction_id} "
|
||||
|
||||
Rails.logger.info(log_string)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,11 +27,48 @@ describe HomeController do
|
|||
end
|
||||
|
||||
#This describe should apply to any controller class. HomeController is just the simplest.
|
||||
describe 'logging' do
|
||||
describe 'log overriding in lib/log_overrider' do
|
||||
before do
|
||||
logger = FakeLogger.new
|
||||
Rails.stub(:logger).and_return(FakeLogger.new)
|
||||
end
|
||||
context 'cross-stage' do
|
||||
before do
|
||||
get :show
|
||||
@lines = Rails.logger.infos
|
||||
@id = @lines.first.match(/r_id=(\w+)\s/).captures.first
|
||||
end
|
||||
it 'logs a unified id in a request' do
|
||||
pending "This might require patching Rails"
|
||||
id = @lines.first.match(/r_id=(\w+)\s/).captures.first
|
||||
@lines.each do |line|
|
||||
line.match(/r_id=(\w+)\s/).captures.first.should == @id
|
||||
end
|
||||
end
|
||||
it 'logs different ids in different requests' do
|
||||
pending "This might require patching Rails"
|
||||
get :show
|
||||
old_lines = Rails.logger.infos.select do |line|
|
||||
line.match(/r_id=(\w+)\s/).captures.first == @id
|
||||
end
|
||||
old_lines.length.should == Rails.logger.infos.length/2
|
||||
end
|
||||
end
|
||||
context 'rendering' do
|
||||
before do
|
||||
get :show, :lasers => 'green'
|
||||
@lines = Rails.logger.infos.select{|l| l.include?("event=render")}
|
||||
end
|
||||
it 'logs all renders' do
|
||||
@lines.length.should == 2
|
||||
end
|
||||
it 'logs layouts' do
|
||||
pending 'where is the template=home/show line?'
|
||||
home_line = @lines.detect{|t|
|
||||
t.include?("template=home/show.html.haml")}
|
||||
home_line.should match /layout=layouts\/application/
|
||||
end
|
||||
|
||||
end
|
||||
context 'completion' do
|
||||
context 'ok' do
|
||||
before do
|
||||
|
|
|
|||
Loading…
Reference in a new issue