airbrake 3.1.10 → 3.1.11

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,32 @@
1
+ Version 3.1.11 - 2013-04-11 12:44:09 +0200
2
+ ===============================================================================
3
+
4
+ Eric Jensen (1):
5
+ add --scm-revision option to cli
6
+
7
+ Hrvoje Šimić (10):
8
+ update tested rails versions
9
+ reverting parts of 8768b1 that caused broken XML
10
+ update integration test
11
+ stop cluttering STDERR from rake airbrake:test
12
+ test coverage for Airbrake::Response
13
+ introduce configurable test mode
14
+ add the test mode option to the generator
15
+ update the test suite to use the test mode accordingly
16
+ stop using the 'progress' format when running features
17
+ fix defaults in integration test
18
+
19
+ Kenneth Kalmer (2):
20
+ Wrap the JS notifier configuration in a try..catch, since the notifier JS might have failed to load
21
+ Set a noop window.onerror in the event Airbrake is not available
22
+
23
+ Mark J. Titorenko (1):
24
+ Use env rather than @env when constructing fallback request data.
25
+
26
+ Marko Šiftar (1):
27
+ pretty formatting of notice details
28
+
29
+
1
30
  Version 3.1.10 - 2013-04-03 15:41:13 +0200
2
31
  ===============================================================================
3
32
 
@@ -1114,3 +1143,4 @@ Nick Quaranto (3):
1114
1143
 
1115
1144
 
1116
1145
 
1146
+
data/README.md CHANGED
@@ -34,9 +34,9 @@ The generator creates a file under `config/initializers/airbrake.rb` configuring
34
34
  The default behaviour of the gem is to only operate in Rails environments that are NOT **development**, **test** & **cucumber**.
35
35
 
36
36
  You can change this by altering this array:
37
-
37
+
38
38
  config.development_environments = ["development", "test", "cucumber", "custom"]
39
-
39
+
40
40
  Set it to empty array and it will report errors on all environments.
41
41
 
42
42
 
@@ -45,7 +45,7 @@ Set it to empty array and it will report errors on all environments.
45
45
  Add the airbrake gem to your app. In config/environment.rb:
46
46
 
47
47
  config.gem 'airbrake'
48
-
48
+
49
49
  or if you are using bundler:
50
50
 
51
51
  gem 'airbrake', :require => 'airbrake/rails'
@@ -89,6 +89,19 @@ After this, you're ready to run the suite with:
89
89
 
90
90
  This will include cucumber features we use to fully test the integration.
91
91
 
92
+ Maintainers
93
+ -----------
94
+
95
+ Make sure all tests are passing before pushing the new version. Also, make sure integration
96
+ test is passing. You can run it with:
97
+
98
+ ./script/integration_test.rb <api_key> <host>
99
+
100
+ After this is passing, change the version inside *lib/airbrake/version.rb* and
101
+ push the new version with Changeling:
102
+
103
+ rake changeling:change
104
+
92
105
  Credits
93
106
  -------
94
107
 
data/Rakefile CHANGED
@@ -123,7 +123,7 @@ LOCAL_GEM_ROOT = File.join(GEM_ROOT, 'tmp', 'local_gems').freeze
123
123
  # various gemfiles. We don't want to, for instance, test sinatra features when
124
124
  # using the rails gemfile and vice versa.
125
125
  def cucumber_opts
126
- opts = "--tags ~@wip --format progress "
126
+ opts = "--tags ~@wip "
127
127
 
128
128
  opts << ENV["FEATURE"] and return if ENV["FEATURE"]
129
129
 
@@ -6,7 +6,7 @@ Feature: Install the Gem in a Rails application
6
6
 
7
7
  Scenario: Use the gem without vendoring the gem in a Rails application
8
8
  When I configure the Airbrake shim
9
- And I run `rails generate airbrake -k myapikey`
9
+ And I run `rails generate airbrake -k myapikey -t`
10
10
  Then I should receive a Airbrake notification
11
11
  And I should see the Rails version
12
12
 
@@ -18,7 +18,7 @@ Feature: Install the Gem in a Rails application
18
18
 
19
19
  Scenario: Configuration within initializer isn't overridden by Railtie
20
20
  When I configure the Airbrake shim
21
- And I run `rails generate airbrake -k myapikey`
21
+ And I run `rails generate airbrake -k myapikey -t`
22
22
  And I configure the notifier to use the following configuration lines:
23
23
  """
24
24
  config.api_key = "myapikey"
@@ -26,7 +26,6 @@ Feature: Install the Gem in a Rails application
26
26
  """
27
27
  And I define a response for "TestController#index":
28
28
  """
29
- session[:value] = "test"
30
29
  raise RuntimeError, "some message"
31
30
  """
32
31
  And I route "/test/index" to "test#index"
@@ -47,7 +46,7 @@ Feature: Install the Gem in a Rails application
47
46
  Scenario: Configure and deploy using only installed gem
48
47
  When I run `capify .`
49
48
  And I configure the Airbrake shim
50
- And I run `rails generate airbrake -k myapikey`
49
+ And I run `rails generate airbrake -k myapikey -t`
51
50
  And I run `cap -T`
52
51
  Then I should see "airbrake:deploy"
53
52
 
@@ -60,20 +59,18 @@ Feature: Install the Gem in a Rails application
60
59
 
61
60
  Scenario: Rescue an exception in a controller
62
61
  When I configure the Airbrake shim
63
- And I run `rails generate airbrake -k myapikey`
62
+ And I run `rails generate airbrake -k myapikey -t`
64
63
  And I define a response for "TestController#index":
65
64
  """
66
- session[:value] = "test"
67
65
  raise RuntimeError, "some message"
68
66
  """
69
67
  And I route "/test/index" to "test#index"
70
68
  And I perform a request to "http://example.com:123/test/index?param=value"
71
69
  Then I should receive a Airbrake notification
72
- Then I should see "test"
73
70
 
74
71
  Scenario: The gem should not be considered a framework gem
75
72
  When I configure the Airbrake shim
76
- And I run `rails generate airbrake -k myapikey`
73
+ And I run `rails generate airbrake -k myapikey -t`
77
74
  And I run `rake gems`
78
75
  Then I should see that "airbrake" is not considered a framework gem
79
76
 
@@ -87,7 +84,7 @@ Feature: Install the Gem in a Rails application
87
84
  @wip
88
85
  Scenario: Support the Heroku addon in the generator
89
86
  When I configure the Airbrake shim
90
- And I run `rails generate airbrake -k myapikey`
87
+ And I run `rails generate airbrake -k myapikey -t`
91
88
  And I configure the Heroku shim with "myapikey"
92
89
  And I successfully run `rails generate airbrake --heroku`
93
90
  Then I should receive a Airbrake notification
@@ -101,7 +98,7 @@ Feature: Install the Gem in a Rails application
101
98
  Scenario: Support the --app option for the Heroku addon in the generator
102
99
  When I configure the Airbrake shim
103
100
  And I configure the Heroku shim with "myapikey" and multiple app support
104
- And I run `rails generate airbrake --heroku -a myapp`
101
+ And I run `rails generate airbrake --heroku -a myapp -t`
105
102
  Then I should receive a Airbrake notification
106
103
  And I should see the Rails version
107
104
  And my Airbrake configuration should contain the following line:
@@ -111,7 +108,7 @@ Feature: Install the Gem in a Rails application
111
108
 
112
109
  Scenario: Filtering parameters in a controller
113
110
  When I configure the Airbrake shim
114
- And I run `rails generate airbrake -k myapikey`
111
+ And I run `rails generate airbrake -k myapikey -t`
115
112
  When I configure the notifier to use the following configuration lines:
116
113
  """
117
114
  config.api_key = "myapikey"
@@ -128,13 +125,13 @@ Feature: Install the Gem in a Rails application
128
125
  And I route "/test/index" to "test#index"
129
126
  And I perform a request to "http://example.com:123/test/index?param=value" in the "production" environment
130
127
  Then I should receive a Airbrake notification
131
- Then I should not see "red23"
132
- Then I should not see "blue42"
133
- And I should see "FILTERED"
128
+ And the Airbrake notification should not contain "red23"
129
+ And the Airbrake notification should not contain "blue42"
130
+ And the Airbrake notification should contain "FILTERED"
134
131
 
135
132
  Scenario: Filtering session and params based on Rails parameter filters
136
133
  When I configure the Airbrake shim
137
- And I run `rails generate airbrake -k myapikey`
134
+ And I run `rails generate airbrake -k myapikey -t`
138
135
  When I configure the notifier to use the following configuration lines:
139
136
  """
140
137
  config.logger = Logger.new STDOUT
@@ -149,23 +146,23 @@ Feature: Install the Gem in a Rails application
149
146
  And I route "/test/index" to "test#index"
150
147
  And I perform a request to "http://example.com:123/test/index" in the "production" environment
151
148
  Then I should receive a Airbrake notification
152
- And I should not see "red23"
153
- And I should not see "blue42"
154
- And I should see "FILTERED"
149
+ And the Airbrake notification should not contain "red23"
150
+ And the Airbrake notification should not contain "blue42"
151
+ And the Airbrake notification should contain "FILTERED"
155
152
 
156
153
  Scenario: Notify airbrake within the controller
157
154
  When I configure the Airbrake shim
158
- And I run `rails generate airbrake -k myapikey`
155
+ And I run `rails generate airbrake -k myapikey -t`
159
156
  And I define a response for "TestController#index":
160
157
  """
161
- session[:value] = "test"
158
+ session[:value] = "unicorn"
162
159
  notify_airbrake(RuntimeError.new("some message"))
163
160
  render :nothing => true
164
161
  """
165
162
  And I route "/test/index" to "test#index"
166
163
  And I perform a request to "http://example.com:123/test/index?param=value" in the "production" environment
167
164
  Then I should receive a Airbrake notification
168
- And I should see "test"
165
+ And the Airbrake notification should contain "unicorn"
169
166
 
170
167
  Scenario: Reporting 404s should be disabled by default
171
168
  When I configure the Airbrake shim
@@ -179,7 +176,7 @@ Feature: Install the Gem in a Rails application
179
176
 
180
177
  Scenario: Reporting 404s should work when configured properly
181
178
  When I configure the Airbrake shim
182
- And I run `rails generate airbrake -k myapikey`
179
+ And I run `rails generate airbrake -k myapikey -t`
183
180
  When I configure the notifier to use the following configuration lines:
184
181
  """
185
182
  config.ignore_only = []
@@ -191,7 +188,7 @@ Feature: Install the Gem in a Rails application
191
188
  @wip
192
189
  Scenario: reporting over SSL with utf8 check should work
193
190
  When I configure the Airbrake shim
194
- And I run `rails generate airbrake -k myapikey`
191
+ And I run `rails generate airbrake -k myapikey -t`
195
192
  When I configure the notifier to use the following configuration lines:
196
193
  """
197
194
  config.secure = true
@@ -43,6 +43,7 @@ end
43
43
  When /^I configure the notifier to use the following configuration lines:$/ do |configuration_lines|
44
44
  initializer_code = <<-EOF
45
45
  Airbrake.configure do |config|
46
+ config.test_mode = true
46
47
  #{configuration_lines}
47
48
  end
48
49
  EOF
@@ -234,19 +235,38 @@ When /^I have set up authentication system in my app that uses "([^\"]*)"$/ do |
234
235
  File.open(application_controller, "w") {|file| file.puts definition }
235
236
  end
236
237
 
238
+ Then /^the Airbrake notification should contain "([^\"]*)"$/ do |content|
239
+ step %{the last notice sent should contain "#{content}"}
240
+ end
241
+
242
+ Then /^the Airbrake notification should not contain "([^\"]*)"$/ do |content|
243
+ step %{the last notice sent should not contain "#{content}"}
244
+ end
245
+
237
246
  Then /^the Airbrake notification should contain the custom user details$/ do
238
- step %{I should see "<name>Bender</name>"}
239
- step %{I should see "<email>bender@beer.com</email>"}
240
- step %{I should see "<username>b3nd0r</username>"}
241
- step %{I should see "<class_name>User</class_name>"}
247
+ step %{the last notice sent should contain "<name>Bender</name>"}
248
+ step %{the last notice sent should contain "<email>bender@beer.com</email>"}
249
+ step %{the last notice sent should contain "<username>b3nd0r</username>"}
250
+ step %{the last notice sent should contain "<class_name>User</class_name>"}
242
251
  end
243
252
 
244
253
  Then /^the Airbrake notification should contain user details$/ do
245
- step %{I should see "<id>1</id>"}
254
+ step %{the last notice sent should contain "<id>1</id>"}
255
+ end
256
+
257
+ Then /^the last notice sent should contain "([^\"]*)"$/ do |data|
258
+ last_notice = File.read(LAST_NOTICE)
259
+ last_notice.should match(%r{#{data}})
260
+ end
261
+
262
+ Then /^the last notice sent should not contain "([^\"]*)"$/ do |data|
263
+ last_notice = File.read(LAST_NOTICE)
264
+ last_notice.should_not match(%r{#{data}})
246
265
  end
247
266
 
267
+
248
268
  Then /^the Airbrake notification should contain the framework information$/ do
249
- step %{the output should contain "Rails: #{ENV["RAILS_VERSION"]}"}
269
+ step %{the last notice sent should contain "Rails: #{ENV["RAILS_VERSION"]}"}
250
270
  end
251
271
 
252
272
  When /^I list the application's middleware and save it into a file$/ do
@@ -261,4 +281,3 @@ Then /^the Airbrake middleware should be placed correctly$/ do
261
281
  middleware.rindex("use ActionDispatch::ShowExceptions")
262
282
  (airbrake_index > middleware_index).should be_true
263
283
  end
264
-
@@ -6,9 +6,6 @@ ShamRack.at("api.airbrake.io") do |env|
6
6
  <id>b6817316-9c45-ed26-45eb-780dbb86aadb</id>
7
7
  <url>http://airbrake.io/locate/b6817316-9c45-ed26-45eb-780dbb86aadb</url>
8
8
  </notice>
9
-
10
- Request:
11
- #{env["rack.input"].read}
12
9
  end_xml
13
10
  ["200 OK", { "Content-type" => "text/xml" }, [response]]
14
11
  end
@@ -7,6 +7,7 @@ PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'
7
7
  TEMP_DIR = File.join(PROJECT_ROOT, 'tmp').freeze
8
8
  LOCAL_RAILS_ROOT = File.join(TEMP_DIR, 'rails_root').freeze
9
9
  RACK_FILE = File.join(TEMP_DIR, 'rack_app.rb').freeze
10
+ LAST_NOTICE = File.join(PROJECT_ROOT, 'resources', 'notice.xml')
10
11
 
11
12
  Before do
12
13
  FileUtils.rm_rf(LOCAL_RAILS_ROOT)
@@ -122,11 +122,10 @@ module RailsHelpers
122
122
  File.open(rakefile_path, 'wb') { |file| file.write(content) }
123
123
  end
124
124
 
125
- def perform_request(uri, environment = 'production')
125
+ def perform_request(uri, environment = 'production')
126
126
  request_script = <<-SCRIPT
127
127
  require File.expand_path('../config/environment', __FILE__)
128
128
 
129
-
130
129
  env = Rack::MockRequest.env_for(#{uri.inspect})
131
130
  response = RailsRoot::Application.call(env)
132
131
 
data/lib/airbrake.rb CHANGED
@@ -19,6 +19,7 @@ require 'airbrake/version'
19
19
  require 'airbrake/configuration'
20
20
  require 'airbrake/notice'
21
21
  require 'airbrake/sender'
22
+ require 'airbrake/response'
22
23
  require 'airbrake/backtrace'
23
24
  require 'airbrake/rack'
24
25
  require 'airbrake/sinatra'
@@ -51,7 +52,7 @@ module Airbrake
51
52
 
52
53
  # Prints out the response body from Airbrake for debugging help
53
54
  def report_response_body(response)
54
- write_verbose_log("Response from Airbrake: \n#{response}")
55
+ write_verbose_log("Response from Airbrake: \n#{Response.pretty_format(response)}")
55
56
  end
56
57
 
57
58
  # Prints out the details about the notice that wasn't sent to server
@@ -85,7 +86,12 @@ module Airbrake
85
86
  # end
86
87
  def configure(silent = false)
87
88
  yield(configuration)
88
- self.sender = Sender.new(configuration)
89
+ self.sender = if configuration.test_mode?
90
+ CollectingSender.new(configuration)
91
+ else
92
+ Sender.new(configuration)
93
+ end
94
+
89
95
  report_ready unless silent
90
96
  self.sender
91
97
  end
@@ -33,7 +33,9 @@ module Client
33
33
  "/projects/1/deploys.xml"
34
34
  http = Net::HTTP.new(uri.host,uri.port)
35
35
  request = Net::HTTP::Post.new(uri.request_uri)
36
- request.set_form_data('deploy[rails_env]' => options.rails_env,"api_key" => options.api_key)
36
+ opts = {'deploy[rails_env]' => options.rails_env,"api_key" => options.api_key}
37
+ opts.merge!('deploy[scm_revision]' => options.scm_revision) if options.scm_revision
38
+ request.set_form_data(opts)
37
39
  response = http.request(request)
38
40
  puts response.body
39
41
  end
@@ -1,6 +1,6 @@
1
1
  class Options
2
2
 
3
- ATTRIBUTES = [:error, :message, :api_key, :host, :port, :auth_token, :name, :account, :rails_env]
3
+ ATTRIBUTES = [:error, :message, :api_key, :host, :port, :auth_token, :name, :account, :rails_env, :scm_revision]
4
4
 
5
5
  ATTRIBUTES.each do |attribute|
6
6
  attr_reader attribute
@@ -27,6 +27,7 @@ class Options
27
27
  self.name = opts.delete("-n") || opts.delete("--name")
28
28
  self.account = opts.delete("-a") || opts.delete("--account") || ENV["AIRBRAKE_ACCOUNT"]
29
29
  self.rails_env = opts.delete("-E") || opts.delete("--rails-env") || ENV["RAILS_ENV"] || "production"
30
+ self.scm_revision = opts.delete("-r") || opts.delete("--scm-revision")
30
31
  opts
31
32
  end
32
33
 
@@ -8,7 +8,8 @@ module Airbrake
8
8
  :ignore_user_agent, :notifier_name, :notifier_url, :notifier_version,
9
9
  :params_filters, :project_root, :port, :protocol, :proxy_host,
10
10
  :proxy_pass, :proxy_port, :proxy_user, :secure, :use_system_ssl_cert_chain,
11
- :framework, :user_information, :rescue_rake_exceptions, :rake_environment_filters].freeze
11
+ :framework, :user_information, :rescue_rake_exceptions, :rake_environment_filters,
12
+ :test_mode].freeze
12
13
 
13
14
  # The API key for your project, found on the project edit form.
14
15
  attr_accessor :api_key
@@ -110,6 +111,10 @@ module Airbrake
110
111
  # Only used for JSON API
111
112
  attr_accessor :project_id
112
113
 
114
+ # Setting this to true will use the CollectingSender instead of
115
+ # the default one which will cause storing the last notice locally
116
+ attr_accessor :test_mode
117
+ alias_method :test_mode?, :test_mode
113
118
 
114
119
  DEFAULT_PARAMS_FILTERS = %w(password password_confirmation).freeze
115
120
 
@@ -159,7 +159,7 @@ module Airbrake
159
159
  backtrace.line(
160
160
  :number => line.number,
161
161
  :file => line.file,
162
- :method_name => line.method_name
162
+ :method => line.method_name
163
163
  )
164
164
  end
165
165
  end
@@ -1,6 +1,16 @@
1
1
  require 'airbrake'
2
2
  require File.join(File.dirname(__FILE__), 'shared_tasks')
3
3
 
4
+ # Override error handling in Rack so we don't clutter STDERR
5
+ # with unnecesarry stack trace
6
+ Rake.application.instance_eval do
7
+ class << self
8
+ def display_error_message(exception)
9
+ puts exception
10
+ end
11
+ end
12
+ end
13
+
4
14
  namespace :airbrake do
5
15
  desc "Verify your gem installation by sending a test exception to the airbrake service"
6
16
  task :test => [:environment] do
@@ -27,6 +37,7 @@ namespace :airbrake do
27
37
  end
28
38
 
29
39
  # Override Rails exception middleware, so we stop cluttering STDOUT
40
+ # with stack trace from Rails
30
41
  class ActionDispatch::DebugExceptions; def call(env); @app.call(env); end; end
31
42
  class ActionDispatch::ShowExceptions; def call(env); @app.call(env); end; end
32
43
 
@@ -0,0 +1,31 @@
1
+ module Airbrake
2
+ class Response
3
+ def self.pretty_format(xml_body)
4
+ new(xml_body)
5
+ rescue
6
+ xml_body
7
+ end
8
+
9
+ def to_s
10
+ output = "\n"
11
+ output = "UUID: #{id}"
12
+ output << "\n"
13
+ output << "URL: #{url}"
14
+ output
15
+ end
16
+
17
+ private
18
+
19
+ attr_accessor :xml_body, :url, :id
20
+
21
+ def initialize(xml_body)
22
+ self.xml_body = xml_body
23
+ self.url = parse_tag("url")
24
+ self.id = parse_tag("id")
25
+ end
26
+
27
+ def parse_tag(name)
28
+ xml_body.match(%r{<#{name}[^>]*>(.*?)</#{name}>})[1]
29
+ end
30
+ end
31
+ end
@@ -177,4 +177,30 @@ module Airbrake
177
177
  project_id.present?
178
178
  end
179
179
  end
180
+
181
+ class CollectingSender < Sender
182
+ # Used when test mode is enabled, to store the last XML notice locally
183
+
184
+ attr_writer :last_notice_path
185
+
186
+ def last_notice
187
+ File.read last_notice_path
188
+ end
189
+
190
+ def last_notice_path
191
+ File.expand_path(File.join("..", "..", "..", "resources", "notice.xml"), __FILE__)
192
+ end
193
+
194
+ def send_to_airbrake(notice)
195
+ data = prepare_notice(notice)
196
+
197
+ notices_file = File.open(last_notice_path, "w") do |file|
198
+ file.puts data
199
+ end
200
+
201
+ super(notice)
202
+ ensure
203
+ notices_file.close if notices_file
204
+ end
205
+ end
180
206
  end
@@ -1,3 +1,3 @@
1
1
  module Airbrake
2
- VERSION = "3.1.10"
2
+ VERSION = "3.1.11"
3
3
  end
@@ -15,6 +15,9 @@ class AirbrakeGenerator < Rails::Generators::Base
15
15
  class_option :secure, :type => :boolean,
16
16
  :desc => "Use SSL connection"
17
17
 
18
+ class_option :test_mode, :aliases => "-t", :type => :boolean,
19
+ :desc => "Use Airbrake in test mode"
20
+
18
21
  def self.source_root
19
22
  @_airbrake_source_root ||= File.expand_path("../../../../../generators/airbrake/templates", __FILE__)
20
23
  end
@@ -93,6 +96,10 @@ class AirbrakeGenerator < Rails::Generators::Base
93
96
  options[:secure]
94
97
  end
95
98
 
99
+ def test_mode?
100
+ options[:test_mode]
101
+ end
102
+
96
103
  def heroku?
97
104
  options[:heroku] ||
98
105
  system("grep AIRBRAKE_API_KEY config/initializers/airbrake.rb") ||
@@ -117,7 +124,8 @@ Airbrake.configure do |config|
117
124
  config.api_key = #{api_key_expression}
118
125
  eos
119
126
 
120
- output << " config.secure = true" if secure?
121
- output << "\nend"
127
+ output << " config.secure = true\n" if secure?
128
+ output << " config.test_mode = true\n" if test_mode?
129
+ output << "end"
122
130
  end
123
131
  end
@@ -6,10 +6,15 @@
6
6
  }%>
7
7
 
8
8
  <%= javascript_tag %Q{
9
+ try {
9
10
  window.Airbrake = (typeof(Airbrake) == 'undefined' && typeof(Hoptoad) != 'undefined') ? Hoptoad : Airbrake
10
11
  Airbrake.setKey('#{api_key}');
11
12
  Airbrake.setHost('#{host}');
12
13
  Airbrake.setEnvironment('#{environment}');
13
14
  Airbrake.setErrorDefaults({ url: "#{escape_javascript url}", component: "#{controller_name}", action: "#{action_name}" });
14
15
  }
16
+ catch (e) {
17
+ window.onerror = null;
18
+ }
19
+ }
15
20
  %>
@@ -38,7 +38,7 @@
38
38
  <xs:complexType>
39
39
  <xs:attribute name="file" type="xs:string" use="required"/>
40
40
  <xs:attribute name="number" type="xs:string" use="required"/>
41
- <xs:attribute name="method_name" type="xs:string" use="optional"/>
41
+ <xs:attribute name="method" type="xs:string" use="optional"/>
42
42
  </xs:complexType>
43
43
  </xs:element>
44
44
  </xs:sequence>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><notice version="2.4"><api-key/><notifier><name>Airbrake Notifier</name><version>3.1.10</version><url>https://github.com/airbrake/airbrake</url></notifier><error><class>RuntimeError</class><message>RuntimeError: some message</message><backtrace><line number="5" file="[PROJECT_ROOT]/app/controllers/test_controller.rb" method="index"/><line number="4" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_controller/metal/implicit_render.rb" method="send_action"/><line number="167" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/abstract_controller/base.rb" method="process_action"/><line number="10" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_controller/metal/rendering.rb" method="process_action"/><line number="18" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/abstract_controller/callbacks.rb" method="block in process_action"/><line number="414" file="[GEM_ROOT]/gems/activesupport-3.2.13/lib/active_support/callbacks.rb" method="_run__1119964459555507863__process_action__2114797969435458246__callbacks"/><line number="405" file="[GEM_ROOT]/gems/activesupport-3.2.13/lib/active_support/callbacks.rb" method="__run_callback"/><line number="385" file="[GEM_ROOT]/gems/activesupport-3.2.13/lib/active_support/callbacks.rb" method="_run_process_action_callbacks"/><line number="81" file="[GEM_ROOT]/gems/activesupport-3.2.13/lib/active_support/callbacks.rb" method="run_callbacks"/><line number="17" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/abstract_controller/callbacks.rb" method="process_action"/><line number="29" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_controller/metal/rescue.rb" method="process_action"/><line number="30" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb" method="block in process_action"/><line number="123" file="[GEM_ROOT]/gems/activesupport-3.2.13/lib/active_support/notifications.rb" method="block in instrument"/><line number="20" file="[GEM_ROOT]/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb" method="instrument"/><line number="123" file="[GEM_ROOT]/gems/activesupport-3.2.13/lib/active_support/notifications.rb" method="instrument"/><line number="29" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb" method="process_action"/><line number="207" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_controller/metal/params_wrapper.rb" method="process_action"/><line number="121" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/abstract_controller/base.rb" method="process"/><line number="45" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb" method="process"/><line number="203" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_controller/metal.rb" method="dispatch"/><line number="14" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_controller/metal/rack_delegation.rb" method="dispatch"/><line number="246" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_controller/metal.rb" method="block in action"/><line number="73" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb" method="call"/><line number="73" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb" method="dispatch"/><line number="36" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb" method="call"/><line number="68" file="[GEM_ROOT]/gems/journey-1.0.4/lib/journey/router.rb" method="block in call"/><line number="56" file="[GEM_ROOT]/gems/journey-1.0.4/lib/journey/router.rb" method="each"/><line number="56" file="[GEM_ROOT]/gems/journey-1.0.4/lib/journey/router.rb" method="call"/><line number="612" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb" method="call"/><line number="17" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_dispatch/middleware/best_standards_support.rb" method="call"/><line number="23" file="[GEM_ROOT]/gems/rack-1.4.5/lib/rack/etag.rb" method="call"/><line number="25" file="[GEM_ROOT]/gems/rack-1.4.5/lib/rack/conditionalget.rb" method="call"/><line number="14" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_dispatch/middleware/head.rb" method="call"/><line number="21" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_dispatch/middleware/params_parser.rb" method="call"/><line number="242" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_dispatch/middleware/flash.rb" method="call"/><line number="210" file="[GEM_ROOT]/gems/rack-1.4.5/lib/rack/session/abstract/id.rb" method="context"/><line number="205" file="[GEM_ROOT]/gems/rack-1.4.5/lib/rack/session/abstract/id.rb" method="call"/><line number="341" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_dispatch/middleware/cookies.rb" method="call"/><line number="28" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb" method="block in call"/><line number="405" file="[GEM_ROOT]/gems/activesupport-3.2.13/lib/active_support/callbacks.rb" method="_run__1576280847308009310__call__2543261213916389519__callbacks"/><line number="405" file="[GEM_ROOT]/gems/activesupport-3.2.13/lib/active_support/callbacks.rb" method="__run_callback"/><line number="385" file="[GEM_ROOT]/gems/activesupport-3.2.13/lib/active_support/callbacks.rb" method="_run_call_callbacks"/><line number="81" file="[GEM_ROOT]/gems/activesupport-3.2.13/lib/active_support/callbacks.rb" method="run_callbacks"/><line number="27" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb" method="call"/><line number="31" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_dispatch/middleware/remote_ip.rb" method="call"/><line number="16" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_dispatch/middleware/debug_exceptions.rb" method="call"/><line number="56" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_dispatch/middleware/show_exceptions.rb" method="call"/><line number="32" file="[GEM_ROOT]/gems/railties-3.2.13/lib/rails/rack/logger.rb" method="call_app"/><line number="16" file="[GEM_ROOT]/gems/railties-3.2.13/lib/rails/rack/logger.rb" method="block in call"/><line number="22" file="[GEM_ROOT]/gems/activesupport-3.2.13/lib/active_support/tagged_logging.rb" method="tagged"/><line number="16" file="[GEM_ROOT]/gems/railties-3.2.13/lib/rails/rack/logger.rb" method="call"/><line number="22" file="[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_dispatch/middleware/request_id.rb" method="call"/><line number="21" file="[GEM_ROOT]/gems/rack-1.4.5/lib/rack/methodoverride.rb" method="call"/><line number="17" file="[GEM_ROOT]/gems/rack-1.4.5/lib/rack/runtime.rb" method="call"/><line number="72" file="[GEM_ROOT]/gems/activesupport-3.2.13/lib/active_support/cache/strategy/local_cache.rb" method="call"/><line number="15" file="[GEM_ROOT]/gems/rack-1.4.5/lib/rack/lock.rb" method="call"/><line number="136" file="[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb" method="forward"/><line number="245" file="[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb" method="fetch"/><line number="185" file="[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb" method="lookup"/><line number="66" file="[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb" method="call!"/><line number="51" file="[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb" method="call"/><line number="479" file="[GEM_ROOT]/gems/railties-3.2.13/lib/rails/engine.rb" method="call"/><line number="223" file="[GEM_ROOT]/gems/railties-3.2.13/lib/rails/application.rb" method="call"/><line number="30" file="[GEM_ROOT]/gems/railties-3.2.13/lib/rails/railtie/configurable.rb" method="method_missing"/><line number="4" file="request.rb" method="&lt;top (required)&gt;"/><line number="51" file="[GEM_ROOT]/gems/railties-3.2.13/lib/rails/commands/runner.rb" method="eval"/><line number="51" file="[GEM_ROOT]/gems/railties-3.2.13/lib/rails/commands/runner.rb" method="&lt;top (required)&gt;"/><line number="64" file="[GEM_ROOT]/gems/railties-3.2.13/lib/rails/commands.rb" method="require"/><line number="64" file="[GEM_ROOT]/gems/railties-3.2.13/lib/rails/commands.rb" method="&lt;top (required)&gt;"/><line number="6" file="script/rails" method="require"/><line number="6" file="script/rails" method="&lt;main&gt;"/></backtrace></error><request><url>http://example.com:123/test/index?param=value</url><component>test</component><action>index</action><params><var key="param">value</var><var key="controller">test</var><var key="action">index</var></params><cgi-data><var key="rack.version">["1", "1"]</var><var key="rack.input">#&lt;StringIO:0x000000021d3498&gt;</var><var key="rack.errors">#&lt;StringIO:0x000000021d3560&gt;</var><var key="rack.multithread">false</var><var key="rack.multiprocess">true</var><var key="rack.run_once">false</var><var key="REQUEST_METHOD">GET</var><var key="SERVER_NAME">example.com</var><var key="SERVER_PORT">123</var><var key="QUERY_STRING">param=value</var><var key="PATH_INFO">/test/index</var><var key="rack.url_scheme">http</var><var key="HTTPS">off</var><var key="SCRIPT_NAME"></var><var key="CONTENT_LENGTH">0</var><var key="ORIGINAL_FULLPATH">/test/index?param=value</var><var key="action_dispatch.routes">#&lt;ActionDispatch::Routing::RouteSet:0x00000001ae8ea8&gt;</var><var key="action_dispatch.parameter_filter">["password"]</var><var key="action_dispatch.show_exceptions">true</var><var key="action_dispatch.show_detailed_exceptions">false</var><var key="action_dispatch.logger">#&lt;ActiveSupport::TaggedLogging:0x0000000174daf0&gt;</var><var key="action_dispatch.backtrace_cleaner">#&lt;Rails::BacktraceCleaner:0x00000002cb9218&gt;</var><var key="rack-cache.cache_key">Rack::Cache::Key</var><var key="rack-cache.verbose">false</var><var key="rack-cache.storage">#&lt;Rack::Cache::Storage:0x00000002168b70&gt;</var><var key="rack-cache.metastore">rails:/</var><var key="rack-cache.entitystore">rails:/</var><var key="rack-cache.default_ttl">0</var><var key="rack-cache.ignore_headers">["Set-Cookie"]</var><var key="rack-cache.private_headers">["Authorization", "Cookie"]</var><var key="rack-cache.allow_reload">false</var><var key="rack-cache.allow_revalidate">false</var><var key="rack-cache.use_native_ttl">false</var><var key="action_dispatch.request_id">2c43f3810b99b182954b910220833d5a</var><var key="action_dispatch.remote_ip"></var><var key="rack.session"></var><var key="rack.session.options"><var key="path">/</var><var key="domain"></var><var key="expire_after"></var><var key="secure">false</var><var key="httponly">true</var><var key="defer">false</var><var key="renew">false</var><var key="secret">bb299e2337398a11690d55a857c1570cc8f62f19b5907d6b7ff9fd9d495a</var><var key="coder">#&lt;Rack::Session::Cookie::Base64::Marshal:0x000000015f19e0&gt;</var><var key="id"></var></var><var key="rack.request.cookie_hash"></var><var key="action_dispatch.cookies">#&lt;ActionDispatch::Cookies::CookieJar:0x000000030c17e8&gt;</var><var key="action_dispatch.request.unsigned_session_cookie"></var><var key="action_dispatch.request.path_parameters"><var key="controller">test</var><var key="action">index</var></var><var key="action_controller.instance">#&lt;TestController:0x000000025fd7d0&gt;</var><var key="action_dispatch.request.content_type"></var><var key="action_dispatch.request.request_parameters"></var><var key="rack.request.query_string">param=value</var><var key="rack.request.query_hash"><var key="param">value</var></var><var key="action_dispatch.request.query_parameters"><var key="param">value</var></var><var key="action_dispatch.request.parameters"><var key="param">value</var><var key="controller">test</var><var key="action">index</var></var><var key="action_dispatch.request.formats">["text/html"]</var></cgi-data></request><server-environment><project-root>/home/hrvoje/code/airbrake/tmp/rails_root</project-root><environment-name>production</environment-name><hostname>hrvoje-Aspire-5741G</hostname></server-environment><framework>Rails: 3.2.13</framework></notice>
@@ -9,30 +9,27 @@ RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
9
9
 
10
10
  $: << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
11
11
  require 'airbrake'
12
- require 'rails/init'
13
12
 
14
13
  fail "Please supply an API Key as the first argument" if ARGV.empty?
15
14
 
16
- host = ARGV[1]
17
- host ||= "api.airbrake.io"
18
-
19
- secure = (ARGV[2] == "secure")
20
-
21
- exception = begin
22
- raise "Testing airbrake notifier with secure = #{secure}. If you can see this, it works."
23
- rescue => foo
24
- foo
25
- end
15
+ host = ARGV[1] || "api.airbrake.io"
16
+ port = ARGV[2] || 80
17
+ secure = (ARGV[3] == "secure")
18
+ exception = RuntimeError.new "Testing airbrake notifier with secure = #{secure}. If you can see this, it works."
26
19
 
27
20
  Airbrake.configure do |config|
28
- config.secure = secure
29
- config.host = host
30
- config.api_key = ARGV.first
21
+ config.secure = secure
22
+ config.host = host
23
+ config.port = port
24
+ config.api_key = ARGV.first
31
25
  end
26
+
32
27
  puts "Configuration:"
33
28
  Airbrake.configuration.to_hash.each do |key, value|
34
29
  puts sprintf("%25s: %s", key.to_s, value.inspect.slice(0, 55))
35
30
  end
36
- puts "Sending #{secure ? "" : "in"}secure notification to project with key #{ARGV.first}"
37
- Airbrake.notify(exception)
38
31
 
32
+ puts "Sending #{secure ? "" : "in"}secure notification to project with key #{ARGV.first}"
33
+ if Airbrake.notify(exception) then puts "\nIntegration test passed with success!"
34
+ else puts "\nIntegration test was unsuccessful."
35
+ end
data/test/notice_test.rb CHANGED
@@ -351,7 +351,7 @@ class NoticeTest < Test::Unit::TestCase
351
351
 
352
352
  assert_valid_node(@document, "//error/backtrace/line/@number", @notice.backtrace.lines.first.number)
353
353
  assert_valid_node(@document, "//error/backtrace/line/@file", @notice.backtrace.lines.first.file)
354
- assert_valid_node(@document, "//error/backtrace/line/@method_name", @notice.backtrace.lines.first.method_name)
354
+ assert_valid_node(@document, "//error/backtrace/line/@method", @notice.backtrace.lines.first.method_name)
355
355
 
356
356
  assert_valid_node(@document, "//request/url", @notice.url)
357
357
  assert_valid_node(@document, "//request/component", @notice.controller)
@@ -0,0 +1,18 @@
1
+ require File.expand_path '../helper', __FILE__
2
+
3
+ class ResponseTest < Test::Unit::TestCase
4
+ include DefinesConstants
5
+
6
+ def response_body
7
+ File.read File.expand_path('../support/response_shim.xml', __FILE__)
8
+ end
9
+
10
+ should "output a nicely formatted notice details" do
11
+ output = Airbrake::Response.pretty_format(response_body)
12
+
13
+ assert %r{ID: b6817316-9c45-ed26-45eb-780dbb86aadb}, "#{output}"
14
+ assert %r{URL: http://airbrake.io/locate/b6817316-9c45-ed26-45eb-780dbb86aadb},
15
+ "#{output}"
16
+
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ <notice>
2
+ <id>fd2ec31a-8628-0146-edae-b783ab246f9f</id>
3
+ <url>http://airbrake.io/locate/fd2ec31a-8628-0146-edae-b783ab246f9f</url>
4
+ </notice>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.10
4
+ version: 3.1.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-03 00:00:00.000000000 Z
12
+ date: 2013-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder
@@ -308,6 +308,7 @@ files:
308
308
  - lib/airbrake/capistrano.rb
309
309
  - lib/airbrake/rake_handler.rb
310
310
  - lib/airbrake/sinatra.rb
311
+ - lib/airbrake/response.rb
311
312
  - lib/rails/generators/airbrake/airbrake_generator.rb
312
313
  - lib/templates/javascript_notifier.erb
313
314
  - lib/templates/rescue.erb
@@ -317,6 +318,7 @@ files:
317
318
  - resources/airbrake_2_4.xsd
318
319
  - resources/README.md
319
320
  - resources/airbrake_3_0.json
321
+ - resources/notice.xml
320
322
  - script/integration_test.rb
321
323
  - airbrake.gemspec
322
324
  - CHANGELOG
@@ -336,6 +338,7 @@ files:
336
338
  - test/airbrake_tasks_test.rb
337
339
  - test/controller_methods_test.rb
338
340
  - test/rack_test.rb
341
+ - test/response_test.rb
339
342
  - test/notice_test.rb
340
343
  - test/helper.rb
341
344
  - test/javascript_notifier_test.rb
@@ -343,6 +346,7 @@ files:
343
346
  - test/catcher_test.rb
344
347
  - test/rails_initializer_test.rb
345
348
  - test/capistrano_test.rb
349
+ - test/support/response_shim.xml
346
350
  - test/user_informer_test.rb
347
351
  - test/logger_test.rb
348
352
  - features/rails.feature
@@ -395,6 +399,7 @@ test_files:
395
399
  - test/airbrake_tasks_test.rb
396
400
  - test/controller_methods_test.rb
397
401
  - test/rack_test.rb
402
+ - test/response_test.rb
398
403
  - test/notice_test.rb
399
404
  - test/helper.rb
400
405
  - test/javascript_notifier_test.rb
@@ -402,6 +407,7 @@ test_files:
402
407
  - test/catcher_test.rb
403
408
  - test/rails_initializer_test.rb
404
409
  - test/capistrano_test.rb
410
+ - test/support/response_shim.xml
405
411
  - test/user_informer_test.rb
406
412
  - test/logger_test.rb
407
413
  - features/rails.feature