From 8afd2efe2159021ca59548525e14dcae528c52ca Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Sat, 12 Jan 2013 17:53:07 +0300 Subject: [PATCH] update airbrake api to 2.4 --- app/models/error_report.rb | 5 +++-- app/models/notice.rb | 1 + app/views/notices/_summary.html.haml | 4 ++++ lib/hoptoad.rb | 4 ++-- lib/hoptoad/v2.rb | 3 ++- spec/fixtures/hoptoad_test_notice.xml | 3 ++- spec/models/app_spec.rb | 5 +++++ spec/views/notices/_summary.html.haml_spec.rb | 12 ++++++++++++ 8 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 spec/views/notices/_summary.html.haml_spec.rb diff --git a/app/models/error_report.rb b/app/models/error_report.rb index 9c40426..dbb6d22 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 + attr_reader :error_class, :message, :request, :server_environment, :api_key, :notifier, :user_attributes, :current_user, :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,8 @@ class ErrorReport :server_environment => server_environment, :notifier => notifier, :user_attributes => user_attributes, - :current_user => current_user + :current_user => current_user, + :framework => framework ) err = app.find_or_create_err!( diff --git a/app/models/notice.rb b/app/models/notice.rb index 2db7167..39d3ad7 100644 --- a/app/models/notice.rb +++ b/app/models/notice.rb @@ -11,6 +11,7 @@ class Notice 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 delegate :app, :problem, :to => :err diff --git a/app/views/notices/_summary.html.haml b/app/views/notices/_summary.html.haml index 2c6136c..f832ef0 100644 --- a/app/views/notices/_summary.html.haml +++ b/app/views/notices/_summary.html.haml @@ -28,6 +28,10 @@ %tr %th App Server %td= notice.server_environment && notice.server_environment["hostname"] + - if notice.framework + %tr + %th Framework + %td= notice.framework %tr %th Rel. Directory %td= notice.server_environment && notice.server_environment["project-root"] diff --git a/lib/hoptoad.rb b/lib/hoptoad.rb index 2c7912a..7e793ec 100644 --- a/lib/hoptoad.rb +++ b/lib/hoptoad.rb @@ -3,7 +3,7 @@ require 'hoptoad/v2' module Hoptoad class ApiVersionError < StandardError def initialize - super "Wrong API Version: Expecting 2.0, 2.1, 2.2 or 2.3" + super "Wrong API Version: Expecting 2.0, 2.1, 2.2, 2.3 or 2.4" end end @@ -16,7 +16,7 @@ module Hoptoad private def self.get_version_processor(version) case version - when /2\.[0123]/; Hoptoad::V2 + when /2\.[01234]/; Hoptoad::V2 else; raise ApiVersionError end end diff --git a/lib/hoptoad/v2.rb b/lib/hoptoad/v2.rb index 89aa006..ef2b3f7 100644 --- a/lib/hoptoad/v2.rb +++ b/lib/hoptoad/v2.rb @@ -60,7 +60,8 @@ module Hoptoad :api_key => notice['api-key'], :notifier => notice['notifier'], :user_attributes => notice['user-attributes'] || {}, - :current_user => notice['current-user'] || {} + :current_user => notice['current-user'] || {}, + :framework => notice['framework'] } end end diff --git a/spec/fixtures/hoptoad_test_notice.xml b/spec/fixtures/hoptoad_test_notice.xml index 3b4591d..d2e1812 100644 --- a/spec/fixtures/hoptoad_test_notice.xml +++ b/spec/fixtures/hoptoad_test_notice.xml @@ -1,11 +1,12 @@ - + APIKEY Hoptoad Notifier 2.3.2 http://hoptoadapp.com + Rails: 3.2.11 HoptoadTestingException HoptoadTestingException: Testing hoptoad via "rake hoptoad:test". If you can see this, it works. diff --git a/spec/models/app_spec.rb b/spec/models/app_spec.rb index 30f850d..8a4c74c 100644 --- a/spec/models/app_spec.rb +++ b/spec/models/app_spec.rb @@ -264,6 +264,11 @@ describe App do @notice.current_user['username'].should == 'mrbean' end + it 'captures the framework' do + @notice = App.report_error!(@xml) + @notice.framework.should == 'Rails: 3.2.11' + end + end diff --git a/spec/views/notices/_summary.html.haml_spec.rb b/spec/views/notices/_summary.html.haml_spec.rb new file mode 100644 index 0000000..cc0f5ac --- /dev/null +++ b/spec/views/notices/_summary.html.haml_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe "notices/_summary.html.haml" do + let(:notice) { Fabricate(:notice, :framework => 'Rails 3.2.11') } + + it "renders application framework" do + render "notices/summary", :notice => notice, :problem => notice.problem + + rendered.should have_content('Rails 3.2.11') + end +end + -- libgit2 0.21.2