From 8e43c55d8e330781c01c452368ad54f205d9f989 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Wed, 6 Mar 2013 12:50:10 +1300 Subject: [PATCH] Use original user_attributes field for current_user details --- app/models/error_report.rb | 3 +-- app/models/notice.rb | 1 - app/views/notices/_user_attributes.html.haml | 8 ++++---- lib/hoptoad/v2.rb | 5 ++--- spec/models/app_spec.rb | 8 ++++---- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/models/error_report.rb b/app/models/error_report.rb index 7711639..6870944 100644 --- a/app/models/error_report.rb +++ b/app/models/error_report.rb @@ -2,7 +2,7 @@ require 'digest/sha1' require 'hoptoad_notifier' class ErrorReport - attr_reader :error_class, :message, :request, :server_environment, :api_key, :notifier, :user_attributes, :current_user, :framework + attr_reader :error_class, :message, :request, :server_environment, :api_key, :notifier, :user_attributes, :framework def initialize(xml_or_attributes) @attributes = (xml_or_attributes.is_a?(String) ? Hoptoad.parse_xml!(xml_or_attributes) : xml_or_attributes).with_indifferent_access @@ -42,7 +42,6 @@ class ErrorReport :server_environment => server_environment, :notifier => notifier, :user_attributes => user_attributes, - :current_user => current_user, :framework => framework ) diff --git a/app/models/notice.rb b/app/models/notice.rb index 52c9420..c82f97b 100644 --- a/app/models/notice.rb +++ b/app/models/notice.rb @@ -10,7 +10,6 @@ class Notice field :request, :type => Hash field :notifier, :type => Hash field :user_attributes, :type => Hash - field :current_user, :type => Hash field :framework field :error_class delegate :lines, :to => :backtrace, :prefix => true diff --git a/app/views/notices/_user_attributes.html.haml b/app/views/notices/_user_attributes.html.haml index 8303994..ee8e906 100644 --- a/app/views/notices/_user_attributes.html.haml +++ b/app/views/notices/_user_attributes.html.haml @@ -2,8 +2,8 @@ %table.user_attributes %tr %td - %strong Information about the user who experienced the error. - - user.each do |user_key, user_value| + %strong The user who experienced the error: + - user.each do |key, value| %tr - %th= user_key - %td= auto_link(user_value.to_s).html_safe + %th= key + %td= auto_link(auto_link(value.to_s, :urls, :target => "_blank"), :email_addresses).html_safe diff --git a/lib/hoptoad/v2.rb b/lib/hoptoad/v2.rb index ef2b3f7..14a8ea6 100644 --- a/lib/hoptoad/v2.rb +++ b/lib/hoptoad/v2.rb @@ -59,11 +59,10 @@ module Hoptoad :api_key => notice['api-key'], :notifier => notice['notifier'], - :user_attributes => notice['user-attributes'] || {}, - :current_user => notice['current-user'] || {}, + # 'current-user' from airbrake, 'user-attributes' from airbrake_user_attributes gem + :user_attributes => notice['current-user'] || notice['user-attributes'] || {}, :framework => notice['framework'] } end end end - diff --git a/spec/models/app_spec.rb b/spec/models/app_spec.rb index 8a4c74c..7ce2717 100644 --- a/spec/models/app_spec.rb +++ b/spec/models/app_spec.rb @@ -258,10 +258,10 @@ describe App do it 'captures the current_user' do @notice = App.report_error!(@xml) - @notice.current_user['id'].should == '123' - @notice.current_user['name'].should == 'Mr. Bean' - @notice.current_user['email'].should == 'mr.bean@example.com' - @notice.current_user['username'].should == 'mrbean' + @notice.user_attributes['id'].should == '123' + @notice.user_attributes['name'].should == 'Mr. Bean' + @notice.user_attributes['email'].should == 'mr.bean@example.com' + @notice.user_attributes['username'].should == 'mrbean' end it 'captures the framework' do -- libgit2 0.21.2