Commit 8afd2efe2159021ca59548525e14dcae528c52ca
1 parent
d3f91ed4
Exists in
master
and in
1 other branch
update airbrake api to 2.4
Showing
8 changed files
with
31 additions
and
6 deletions
Show diff stats
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 | |
| 5 | + attr_reader :error_class, :message, :request, :server_environment, :api_key, :notifier, :user_attributes, :current_user, :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,8 @@ class ErrorReport |
| 42 | 42 | :server_environment => server_environment, |
| 43 | 43 | :notifier => notifier, |
| 44 | 44 | :user_attributes => user_attributes, |
| 45 | - :current_user => current_user | |
| 45 | + :current_user => current_user, | |
| 46 | + :framework => framework | |
| 46 | 47 | ) |
| 47 | 48 | |
| 48 | 49 | err = app.find_or_create_err!( | ... | ... |
app/models/notice.rb
| ... | ... | @@ -11,6 +11,7 @@ class Notice |
| 11 | 11 | field :notifier, :type => Hash |
| 12 | 12 | field :user_attributes, :type => Hash |
| 13 | 13 | field :current_user, :type => Hash |
| 14 | + field :framework | |
| 14 | 15 | field :error_class |
| 15 | 16 | delegate :lines, :to => :backtrace, :prefix => true |
| 16 | 17 | delegate :app, :problem, :to => :err | ... | ... |
app/views/notices/_summary.html.haml
| ... | ... | @@ -28,6 +28,10 @@ |
| 28 | 28 | %tr |
| 29 | 29 | %th App Server |
| 30 | 30 | %td= notice.server_environment && notice.server_environment["hostname"] |
| 31 | + - if notice.framework | |
| 32 | + %tr | |
| 33 | + %th Framework | |
| 34 | + %td= notice.framework | |
| 31 | 35 | %tr |
| 32 | 36 | %th Rel. Directory |
| 33 | 37 | %td= notice.server_environment && notice.server_environment["project-root"] | ... | ... |
lib/hoptoad.rb
| ... | ... | @@ -3,7 +3,7 @@ require 'hoptoad/v2' |
| 3 | 3 | module Hoptoad |
| 4 | 4 | class ApiVersionError < StandardError |
| 5 | 5 | def initialize |
| 6 | - super "Wrong API Version: Expecting 2.0, 2.1, 2.2 or 2.3" | |
| 6 | + super "Wrong API Version: Expecting 2.0, 2.1, 2.2, 2.3 or 2.4" | |
| 7 | 7 | end |
| 8 | 8 | end |
| 9 | 9 | |
| ... | ... | @@ -16,7 +16,7 @@ module Hoptoad |
| 16 | 16 | private |
| 17 | 17 | def self.get_version_processor(version) |
| 18 | 18 | case version |
| 19 | - when /2\.[0123]/; Hoptoad::V2 | |
| 19 | + when /2\.[01234]/; Hoptoad::V2 | |
| 20 | 20 | else; raise ApiVersionError |
| 21 | 21 | end |
| 22 | 22 | end | ... | ... |
lib/hoptoad/v2.rb
| ... | ... | @@ -60,7 +60,8 @@ module Hoptoad |
| 60 | 60 | :api_key => notice['api-key'], |
| 61 | 61 | :notifier => notice['notifier'], |
| 62 | 62 | :user_attributes => notice['user-attributes'] || {}, |
| 63 | - :current_user => notice['current-user'] || {} | |
| 63 | + :current_user => notice['current-user'] || {}, | |
| 64 | + :framework => notice['framework'] | |
| 64 | 65 | } |
| 65 | 66 | end |
| 66 | 67 | end | ... | ... |
spec/fixtures/hoptoad_test_notice.xml
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | -<notice version="2.3"> | |
| 2 | +<notice version="2.4"> | |
| 3 | 3 | <api-key>APIKEY</api-key> |
| 4 | 4 | <notifier> |
| 5 | 5 | <name>Hoptoad Notifier</name> |
| 6 | 6 | <version>2.3.2</version> |
| 7 | 7 | <url>http://hoptoadapp.com</url> |
| 8 | 8 | </notifier> |
| 9 | + <framework>Rails: 3.2.11</framework> | |
| 9 | 10 | <error> |
| 10 | 11 | <class>HoptoadTestingException</class> |
| 11 | 12 | <message>HoptoadTestingException: Testing hoptoad via "rake hoptoad:test". If you can see this, it works.</message> | ... | ... |
spec/models/app_spec.rb
| ... | ... | @@ -264,6 +264,11 @@ describe App do |
| 264 | 264 | @notice.current_user['username'].should == 'mrbean' |
| 265 | 265 | end |
| 266 | 266 | |
| 267 | + it 'captures the framework' do | |
| 268 | + @notice = App.report_error!(@xml) | |
| 269 | + @notice.framework.should == 'Rails: 3.2.11' | |
| 270 | + end | |
| 271 | + | |
| 267 | 272 | end |
| 268 | 273 | |
| 269 | 274 | ... | ... |
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +require 'spec_helper' | |
| 2 | + | |
| 3 | +describe "notices/_summary.html.haml" do | |
| 4 | + let(:notice) { Fabricate(:notice, :framework => 'Rails 3.2.11') } | |
| 5 | + | |
| 6 | + it "renders application framework" do | |
| 7 | + render "notices/summary", :notice => notice, :problem => notice.problem | |
| 8 | + | |
| 9 | + rendered.should have_content('Rails 3.2.11') | |
| 10 | + end | |
| 11 | +end | |
| 12 | + | ... | ... |