Commit 8e43c55d8e330781c01c452368ad54f205d9f989

Authored by Nathan Broadbent
1 parent 13fd21ed
Exists in master and in 1 other branch production

Use original user_attributes field for current_user details

app/models/error_report.rb
... ... @@ -2,7 +2,7 @@ require 'digest/sha1'
2 2 require 'hoptoad_notifier'
3 3  
4 4 class ErrorReport
5   - attr_reader :error_class, :message, :request, :server_environment, :api_key, :notifier, :user_attributes, :current_user, :framework
  5 + attr_reader :error_class, :message, :request, :server_environment, :api_key, :notifier, :user_attributes, :framework
6 6  
7 7 def initialize(xml_or_attributes)
8 8 @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
42 42 :server_environment => server_environment,
43 43 :notifier => notifier,
44 44 :user_attributes => user_attributes,
45   - :current_user => current_user,
46 45 :framework => framework
47 46 )
48 47  
... ...
app/models/notice.rb
... ... @@ -10,7 +10,6 @@ class Notice
10 10 field :request, :type => Hash
11 11 field :notifier, :type => Hash
12 12 field :user_attributes, :type => Hash
13   - field :current_user, :type => Hash
14 13 field :framework
15 14 field :error_class
16 15 delegate :lines, :to => :backtrace, :prefix => true
... ...
app/views/notices/_user_attributes.html.haml
... ... @@ -2,8 +2,8 @@
2 2 %table.user_attributes
3 3 %tr
4 4 %td
5   - %strong Information about the user who experienced the error.
6   - - user.each do |user_key, user_value|
  5 + %strong The user who experienced the error:
  6 + - user.each do |key, value|
7 7 %tr
8   - %th= user_key
9   - %td= auto_link(user_value.to_s).html_safe
  8 + %th= key
  9 + %td= auto_link(auto_link(value.to_s, :urls, :target => "_blank"), :email_addresses).html_safe
... ...
lib/hoptoad/v2.rb
... ... @@ -59,11 +59,10 @@ module Hoptoad
59 59  
60 60 :api_key => notice['api-key'],
61 61 :notifier => notice['notifier'],
62   - :user_attributes => notice['user-attributes'] || {},
63   - :current_user => notice['current-user'] || {},
  62 + # 'current-user' from airbrake, 'user-attributes' from airbrake_user_attributes gem
  63 + :user_attributes => notice['current-user'] || notice['user-attributes'] || {},
64 64 :framework => notice['framework']
65 65 }
66 66 end
67 67 end
68 68 end
69   -
... ...
spec/models/app_spec.rb
... ... @@ -258,10 +258,10 @@ describe App do
258 258  
259 259 it 'captures the current_user' do
260 260 @notice = App.report_error!(@xml)
261   - @notice.current_user['id'].should == '123'
262   - @notice.current_user['name'].should == 'Mr. Bean'
263   - @notice.current_user['email'].should == 'mr.bean@example.com'
264   - @notice.current_user['username'].should == 'mrbean'
  261 + @notice.user_attributes['id'].should == '123'
  262 + @notice.user_attributes['name'].should == 'Mr. Bean'
  263 + @notice.user_attributes['email'].should == 'mr.bean@example.com'
  264 + @notice.user_attributes['username'].should == 'mrbean'
265 265 end
266 266  
267 267 it 'captures the framework' do
... ...