airbrake 3.1.11 → 3.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,23 @@
1
+ Version 3.1.12 - 2013-04-29 18:48:40 +0200
2
+ ===============================================================================
3
+
4
+ Arvind Kunday (1):
5
+ Removing the .erb template handler
6
+
7
+ Hrvoje Šimić (8):
8
+ introducing null logger for fallback
9
+ add missing logger requirement
10
+ being careful with silencing of rake backtrace in the airbrake:test task
11
+ support for Rails 4.0
12
+ start using remote XSD file when verifying XML in tests
13
+ throw a warning for unsupported user attributes
14
+ updating outdated step definition for current user feature
15
+ speeding up the test by using 'runner' instead of 'server'
16
+
17
+ knapo (1):
18
+ Fix Airbrake::Sender#log to log messages when logger is not passed to options.
19
+
20
+
1
21
  Version 3.1.11 - 2013-04-11 12:44:09 +0200
2
22
  ===============================================================================
3
23
 
@@ -1144,3 +1164,4 @@ Nick Quaranto (3):
1144
1164
 
1145
1165
 
1146
1166
 
1167
+
data/Rakefile CHANGED
@@ -16,6 +16,7 @@ task :default do
16
16
  exec 'rake appraisal:rails-3.0 test '\
17
17
  '&& rake appraisal:rails-3.1 test '\
18
18
  '&& rake appraisal:rails-3.2 test '\
19
+ '&& rake appraisal:rails-4.0 test '\
19
20
  '&& rake appraisal cucumber'\
20
21
  end
21
22
 
@@ -23,13 +23,14 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency("nokogiri", "~> 1.5.0")
24
24
  s.add_development_dependency("rspec", "~> 2.6.0")
25
25
  s.add_development_dependency("sham_rack", "~> 1.3.0")
26
- s.add_development_dependency("shoulda", "~> 2.11.3")
27
26
  s.add_development_dependency("capistrano")
28
27
  s.add_development_dependency("aruba")
29
28
  s.add_development_dependency("appraisal")
30
29
  s.add_development_dependency("rspec-rails")
31
30
  s.add_development_dependency("girl_friday")
32
31
  s.add_development_dependency("json-schema")
32
+ s.add_development_dependency("shoulda-matchers")
33
+ s.add_development_dependency("shoulda-context")
33
34
 
34
35
  s.authors = ["Airbrake"]
35
36
  s.email = %q{support@airbrake.io}
@@ -228,7 +228,7 @@ Feature: Install the Gem in a Rails application
228
228
  """
229
229
  config.api_key = "myapikey"
230
230
  config.logger = Logger.new STDOUT
231
- config.user_attributes = [:id, :name, :email, :username, :class_name]
231
+ config.user_attributes = [:id, :name, :email, :username]
232
232
  """
233
233
  And I define a response for "TestController#index":
234
234
  """
@@ -240,6 +240,18 @@ Feature: Install the Gem in a Rails application
240
240
  Then I should receive a Airbrake notification
241
241
  And the Airbrake notification should contain the custom user details
242
242
 
243
+ Scenario: It should warn the user that she's using unsupported attributes for
244
+ current user
245
+ When I configure the Airbrake shim
246
+ And I configure the notifier to use the following configuration lines:
247
+ """
248
+ config.api_key = "myapikey"
249
+ config.logger = Logger.new STDOUT
250
+ config.user_attributes = [:id, :name, :email, :username, :shoe_size]
251
+ """
252
+ And I run `rails runner config/boot.rb`
253
+ Then I should see "Unsupported user attribute: 'shoe_size'"
254
+
243
255
  Scenario: It should log the notice when failure happens
244
256
  When Airbrake server is not responding
245
257
  And I configure the notifier to use the following configuration lines:
@@ -84,7 +84,7 @@ end
84
84
 
85
85
  When /^I perform a request to "([^\"]*)"$/ do |uri|
86
86
  perform_request(uri)
87
- step %{I run `bundle exec ./script/rails runner request.rb`}
87
+ step %{I run `bundle exec rails runner request.rb`}
88
88
  end
89
89
 
90
90
  When /^I perform a request to "([^\"]*)" in the "([^\"]*)" environment$/ do |uri, environment|
@@ -247,7 +247,6 @@ Then /^the Airbrake notification should contain the custom user details$/ do
247
247
  step %{the last notice sent should contain "<name>Bender</name>"}
248
248
  step %{the last notice sent should contain "<email>bender@beer.com</email>"}
249
249
  step %{the last notice sent should contain "<username>b3nd0r</username>"}
250
- step %{the last notice sent should contain "<class_name>User</class_name>"}
251
250
  end
252
251
 
253
252
  Then /^the Airbrake notification should contain user details$/ do
@@ -6,6 +6,7 @@ end
6
6
  require 'net/http'
7
7
  require 'net/https'
8
8
  require 'rubygems'
9
+ require 'logger'
9
10
 
10
11
  begin
11
12
  require 'active_support/core_ext/object/blank'
@@ -74,7 +75,8 @@ module Airbrake
74
75
 
75
76
  # Look for the Rails logger currently defined
76
77
  def logger
77
- self.configuration.logger
78
+ self.configuration.logger ||
79
+ Logger.new(RUBY_PLATFORM =~ /(mingw|bccwin|wince|mswin32)/i ? 'NUL:' : '/dev/null')
78
80
  end
79
81
 
80
82
  # Call this method to modify defaults in your initializers.
@@ -104,9 +104,10 @@ module Airbrake
104
104
  # Should Airbrake catch exceptions from Rake tasks?
105
105
  # (boolean or nil; set to nil to catch exceptions when rake isn't running from a terminal; default is nil)
106
106
  attr_accessor :rescue_rake_exceptions
107
+ alias_method :rescue_rake_exceptions?, :rescue_rake_exceptions
107
108
 
108
109
  # User attributes that are being captured
109
- attr_accessor :user_attributes
110
+ attr_reader :user_attributes
110
111
 
111
112
  # Only used for JSON API
112
113
  attr_accessor :project_id
@@ -116,10 +117,12 @@ module Airbrake
116
117
  attr_accessor :test_mode
117
118
  alias_method :test_mode?, :test_mode
118
119
 
119
- DEFAULT_PARAMS_FILTERS = %w(password password_confirmation).freeze
120
+ DEFAULT_PARAMS_FILTERS = %w(password password_confirmation).freeze
120
121
 
121
122
  DEFAULT_USER_ATTRIBUTES = %w(id).freeze
122
123
 
124
+ VALID_USER_ATTRIBUTES = %w(id name username email).freeze
125
+
123
126
  DEFAULT_BACKTRACE_FILTERS = [
124
127
  lambda { |line|
125
128
  if defined?(Airbrake.configuration.project_root) && Airbrake.configuration.project_root.to_s != ''
@@ -260,6 +263,10 @@ module Airbrake
260
263
  end
261
264
  end
262
265
 
266
+ def user_attributes=(user_attributes)
267
+ @user_attributes = validate_user_attributes user_attributes
268
+ end
269
+
263
270
  # Should Airbrake send notifications asynchronously
264
271
  # (boolean, nil or callable; default is nil).
265
272
  # Can be used as callable-setter when block provided.
@@ -319,5 +326,14 @@ module Airbrake
319
326
  warn "[AIRBRAKE] You can't use the default async handler without girl_friday."\
320
327
  " Please make sure you have girl_friday installed."
321
328
  end
329
+
330
+ def validate_user_attributes(user_attributes)
331
+ user_attributes.each do |attribute|
332
+ next if VALID_USER_ATTRIBUTES.include? attribute
333
+ warn "[AIRBRAKE] Unsupported user attribute: '#{attribute}'. "\
334
+ "This attribute will not be shown in the Airbrake UI. "\
335
+ "Check http://git.io/h6YRpA for more info."
336
+ end
337
+ end
322
338
  end
323
339
  end
@@ -415,9 +415,9 @@ module Airbrake
415
415
  end
416
416
 
417
417
  def also_use_rack_params_filters
418
- if args[:rack_env]
418
+ if cgi_data
419
419
  @params_filters ||= []
420
- @params_filters += rack_request.env["action_dispatch.parameter_filter"] || []
420
+ @params_filters += cgi_data["action_dispatch.parameter_filter"] || []
421
421
  end
422
422
  end
423
423
 
@@ -45,11 +45,11 @@ module Airbrake
45
45
 
46
46
  if respond_to?(:filter_parameters) # Rails 2
47
47
  filter_parameters(hash)
48
- elsif defined?(ActionDispatch::Http::ParameterFilter) # Rails 3
49
- ActionDispatch::Http::ParameterFilter.new(::Rails.application.config.filter_parameters).filter(hash)
48
+ # elsif defined?(ActionDispatch::Http::ParameterFilter) # Rails 3
49
+ # ActionDispatch::Http::ParameterFilter.new(::Rails.application.config.filter_parameters).filter(hash)
50
50
  else
51
51
  hash
52
- end rescue hash
52
+ end
53
53
 
54
54
  end
55
55
 
@@ -8,7 +8,7 @@ module Airbrake
8
8
  private
9
9
 
10
10
  def airbrake_javascript_notifier_options
11
- path = File.join File.dirname(__FILE__), '..', '..', 'templates', 'javascript_notifier.erb'
11
+ path = File.join File.dirname(__FILE__), '..', '..', 'templates', 'javascript_notifier'
12
12
  host = Airbrake.configuration.host.dup
13
13
  port = Airbrake.configuration.port
14
14
  host << ":#{port}" unless [80, 443].include?(port)
@@ -17,6 +17,7 @@ module Airbrake
17
17
  :file => path,
18
18
  :layout => false,
19
19
  :use_full_path => false,
20
+ :handlers => [:erb],
20
21
  :locals => {
21
22
  :host => host,
22
23
  :api_key => Airbrake.configuration.js_api_key,
@@ -1,12 +1,27 @@
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
4
+ def stub_rake_exception_handling!
5
+ # Override error handling in Rack so we don't clutter STDERR
6
+ # with unnecesarry stack trace
7
+ Rake.application.instance_eval do
8
+ class << self
9
+ def display_error_message_silent(exception)
10
+ puts exception
11
+ end
12
+ alias_method :display_error_message_old, :display_error_message
13
+ alias_method :display_error_message, :display_error_message_silent
14
+ end
15
+ end
16
+ end
17
+
18
+ def unstub_rake_exception_handling!
19
+ # Turns Rake exception handling back to normal
20
+ Rake.application.instance_eval do
21
+ class << self
22
+ def display_error_message_silent(exception)
23
+ display_error_message_old(exception)
24
+ end
10
25
  end
11
26
  end
12
27
  end
@@ -14,6 +29,9 @@ end
14
29
  namespace :airbrake do
15
30
  desc "Verify your gem installation by sending a test exception to the airbrake service"
16
31
  task :test => [:environment] do
32
+
33
+ stub_rake_exception_handling!
34
+
17
35
  Rails.logger = defined?(ActiveSupport::TaggedLogging) ?
18
36
  ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) :
19
37
  Logger.new(STDOUT)
@@ -87,7 +105,7 @@ namespace :airbrake do
87
105
  end
88
106
 
89
107
  Rails.application.routes.draw do
90
- get 'verify' => 'application#verify', :as => 'verify'
108
+ get 'verify' => 'application#verify', :as => 'verify', :via => :get
91
109
  end
92
110
 
93
111
  puts 'Processing request.'
@@ -100,5 +118,8 @@ namespace :airbrake do
100
118
  Rails.application.call(env)
101
119
 
102
120
  wait_for_threads if defined? GirlFriday
121
+
122
+ unstub_rake_exception_handling!
103
123
  end
104
124
  end
125
+
@@ -8,19 +8,22 @@ module Airbrake::RakeHandler
8
8
  end
9
9
  end
10
10
 
11
- def display_error_message_with_airbrake(ex)
11
+ def display_error_message_with_airbrake(exception)
12
12
  if Airbrake.sender && Airbrake.configuration &&
13
13
  (Airbrake.configuration.rescue_rake_exceptions ||
14
14
  (Airbrake.configuration.rescue_rake_exceptions===nil && !self.tty_output?))
15
15
 
16
- Airbrake.notify_or_ignore(ex, :component => 'rake', :action => reconstruct_command_line, :cgi_data => environment_info)
16
+ Airbrake.notify_or_ignore(exception,
17
+ :component => 'rake',
18
+ :action => reconstruct_command_line,
19
+ :cgi_data => environment_info)
17
20
  end
18
21
 
19
- display_error_message_without_airbrake(ex)
22
+ display_error_message_without_airbrake(exception)
20
23
  end
21
24
 
22
25
  def reconstruct_command_line
23
- ARGV.join( ' ' )
26
+ ARGV.join(' ')
24
27
  end
25
28
 
26
29
  def environment_info
@@ -137,7 +137,7 @@ module Airbrake
137
137
  end
138
138
 
139
139
  def log(opts = {})
140
- opts[:logger].send opts[:level], LOG_PREFIX + opts[:message] if opts[:logger]
140
+ (opts[:logger] || logger).send(opts[:level], LOG_PREFIX + opts[:message])
141
141
  Airbrake.report_environment_info
142
142
  Airbrake.report_response_body(opts[:response].body) if opts[:response] && opts[:response].respond_to?(:body)
143
143
  Airbrake.report_notice(opts[:notice]) if opts[:notice]
@@ -1,3 +1,3 @@
1
1
  module Airbrake
2
- VERSION = "3.1.11"
2
+ VERSION = "3.1.12"
3
3
  end
@@ -1 +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>
1
+ <?xml version="1.0" encoding="UTF-8"?><notice version="2.4"><api-key>myapikey</api-key><notifier><name>Airbrake Notifier</name><version>3.1.11</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-4.0.0.beta1/lib/action_controller/metal/implicit_render.rb" method="send_action"/><line number="189" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/abstract_controller/base.rb" method="process_action"/><line number="10" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_controller/metal/rendering.rb" method="process_action"/><line number="18" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/abstract_controller/callbacks.rb" method="block in process_action"/><line number="373" file="[GEM_ROOT]/gems/activesupport-4.0.0.beta1/lib/active_support/callbacks.rb" method="_run__2671352232143607105__process_action__callbacks"/><line number="78" file="[GEM_ROOT]/gems/activesupport-4.0.0.beta1/lib/active_support/callbacks.rb" method="run_callbacks"/><line number="17" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/abstract_controller/callbacks.rb" method="process_action"/><line number="29" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_controller/metal/rescue.rb" method="process_action"/><line number="31" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_controller/metal/instrumentation.rb" method="block in process_action"/><line number="158" file="[GEM_ROOT]/gems/activesupport-4.0.0.beta1/lib/active_support/notifications.rb" method="block in instrument"/><line number="20" file="[GEM_ROOT]/gems/activesupport-4.0.0.beta1/lib/active_support/notifications/instrumenter.rb" method="instrument"/><line number="158" file="[GEM_ROOT]/gems/activesupport-4.0.0.beta1/lib/active_support/notifications.rb" method="instrument"/><line number="30" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_controller/metal/instrumentation.rb" method="process_action"/><line number="245" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_controller/metal/params_wrapper.rb" method="process_action"/><line number="136" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/abstract_controller/base.rb" method="process"/><line number="44" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/abstract_controller/rendering.rb" method="process"/><line number="196" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_controller/metal.rb" method="dispatch"/><line number="13" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_controller/metal/rack_delegation.rb" method="dispatch"/><line number="232" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_controller/metal.rb" method="block in action"/><line number="78" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/routing/route_set.rb" method="call"/><line number="78" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/routing/route_set.rb" method="dispatch"/><line number="46" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/routing/route_set.rb" method="call"/><line number="69" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/journey/router.rb" method="block in call"/><line number="57" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/journey/router.rb" method="each"/><line number="57" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/journey/router.rb" method="call"/><line number="651" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/routing/route_set.rb" method="call"/><line number="23" file="[GEM_ROOT]/gems/rack-1.5.2/lib/rack/etag.rb" method="call"/><line number="25" file="[GEM_ROOT]/gems/rack-1.5.2/lib/rack/conditionalget.rb" method="call"/><line number="11" file="[GEM_ROOT]/gems/rack-1.5.2/lib/rack/head.rb" method="call"/><line number="27" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/params_parser.rb" method="call"/><line number="241" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/flash.rb" method="call"/><line number="225" file="[GEM_ROOT]/gems/rack-1.5.2/lib/rack/session/abstract/id.rb" method="context"/><line number="220" file="[GEM_ROOT]/gems/rack-1.5.2/lib/rack/session/abstract/id.rb" method="call"/><line number="452" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/cookies.rb" method="call"/><line number="29" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/callbacks.rb" method="block in call"/><line number="373" file="[GEM_ROOT]/gems/activesupport-4.0.0.beta1/lib/active_support/callbacks.rb" method="_run__4190110547367303363__call__callbacks"/><line number="78" file="[GEM_ROOT]/gems/activesupport-4.0.0.beta1/lib/active_support/callbacks.rb" method="run_callbacks"/><line number="27" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/callbacks.rb" method="call"/><line number="76" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/remote_ip.rb" method="call"/><line number="17" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/debug_exceptions.rb" method="call"/><line number="30" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/show_exceptions.rb" method="call"/><line number="38" file="[GEM_ROOT]/gems/railties-4.0.0.beta1/lib/rails/rack/logger.rb" method="call_app"/><line number="21" file="[GEM_ROOT]/gems/railties-4.0.0.beta1/lib/rails/rack/logger.rb" method="block in call"/><line number="67" file="[GEM_ROOT]/gems/activesupport-4.0.0.beta1/lib/active_support/tagged_logging.rb" method="block in tagged"/><line number="25" file="[GEM_ROOT]/gems/activesupport-4.0.0.beta1/lib/active_support/tagged_logging.rb" method="tagged"/><line number="67" file="[GEM_ROOT]/gems/activesupport-4.0.0.beta1/lib/active_support/tagged_logging.rb" method="tagged"/><line number="21" file="[GEM_ROOT]/gems/railties-4.0.0.beta1/lib/rails/rack/logger.rb" method="call"/><line number="21" file="[GEM_ROOT]/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/request_id.rb" method="call"/><line number="21" file="[GEM_ROOT]/gems/rack-1.5.2/lib/rack/methodoverride.rb" method="call"/><line number="17" file="[GEM_ROOT]/gems/rack-1.5.2/lib/rack/runtime.rb" method="call"/><line number="72" file="[GEM_ROOT]/gems/activesupport-4.0.0.beta1/lib/active_support/cache/strategy/local_cache.rb" method="call"/><line number="510" file="[GEM_ROOT]/gems/railties-4.0.0.beta1/lib/rails/engine.rb" method="call"/><line number="96" file="[GEM_ROOT]/gems/railties-4.0.0.beta1/lib/rails/application.rb" method="call"/><line number="30" file="[GEM_ROOT]/gems/railties-4.0.0.beta1/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-4.0.0.beta1/lib/rails/commands/runner.rb" method="eval"/><line number="51" file="[GEM_ROOT]/gems/railties-4.0.0.beta1/lib/rails/commands/runner.rb" method="&lt;top (required)&gt;"/><line number="86" file="[GEM_ROOT]/gems/railties-4.0.0.beta1/lib/rails/commands.rb" method="require"/><line number="86" file="[GEM_ROOT]/gems/railties-4.0.0.beta1/lib/rails/commands.rb" method="&lt;top (required)&gt;"/><line number="4" file="bin/rails" method="require"/><line number="4" file="bin/rails" method="&lt;main&gt;"/></backtrace></error><request><url>http://example.com:123/test/index</url><component>test</component><action>index</action><params><var key="controller">test</var><var key="action">index</var></params><cgi-data><var key="rack.version">["1", "2"]</var><var key="rack.input">#&lt;StringIO:0x000000037d48a0&gt;</var><var key="rack.errors">#&lt;StringIO:0x000000037d4940&gt;</var><var key="rack.multithread">true</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"></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</var><var key="action_dispatch.routes">#&lt;ActionDispatch::Routing::RouteSet:0x0000000291e5e0&gt;</var><var key="action_dispatch.parameter_filter">["password"]</var><var key="action_dispatch.redirect_filter">[]</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::Logger:0x00000002645210&gt;</var><var key="action_dispatch.backtrace_cleaner">#&lt;Rails::BacktraceCleaner:0x00000003bcb030&gt;</var><var key="action_dispatch.key_generator">#&lt;ActiveSupport::CachingKeyGenerator:0x00000003bca6d0&gt;</var><var key="action_dispatch.http_auth_salt">http authentication</var><var key="action_dispatch.signed_cookie_salt">signed cookie</var><var key="action_dispatch.encrypted_cookie_salt">encrypted cookie</var><var key="action_dispatch.encrypted_signed_cookie_salt">signed encrypted cookie</var><var key="ROUTES_21558000_SCRIPT_NAME"></var><var key="action_dispatch.request_id">5978a867-c5e6-45a9-b2a8-442314b1d5b5</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="id"></var></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:0x00000002729f00&gt;</var><var key="action_dispatch.request.content_type"></var><var key="action_dispatch.request.request_parameters"></var><var key="rack.request.query_string"></var><var key="rack.request.query_hash"></var><var key="action_dispatch.request.query_parameters"></var><var key="action_dispatch.request.parameters"><var key="controller">test</var><var key="action">index</var></var><var key="action_dispatch.request.formats">["text/html"]</var><var key="rack.request.cookie_hash"></var><var key="action_dispatch.cookies">#&lt;ActionDispatch::Cookies::CookieJar:0x00000003b11cc0&gt;</var><var key="action_dispatch.request.unsigned_session_cookie"></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><current-user><id>1</id><name>Bender</name><email>bender@beer.com</email><username>b3nd0r</username></current-user><framework>Rails: 4.0.0.beta1</framework></notice>
@@ -12,7 +12,7 @@ module ActionDispatch
12
12
 
13
13
  # Silence logger
14
14
  def logger
15
- nil
15
+ Logger.new("/dev/null")
16
16
  end
17
17
  end
18
18
  end
@@ -144,148 +144,109 @@ class ActionControllerCatcherTest < ActionDispatch::IntegrationTest
144
144
  end
145
145
 
146
146
 
147
- should "deliver notices from exceptions raised in public requests" do
148
- @app = AirbrakeTestController.action(:boom)
149
- get '/'
150
- assert_caught_and_sent
151
- end
147
+ def deliver_notices_from_exceptions_raised_in_public_requests
148
+ @app = AirbrakeTestController.action(:boom)
149
+ get '/'
150
+ assert_caught_and_sent
151
+ end
152
+
153
+ def not_deliver_notices_from_exceptions_in_development_environments
154
+ Airbrake.configuration.development_environments = ["test"]
155
+ Airbrake.configuration.environment_name = "test"
156
+ @app = AirbrakeTestController.action(:boom)
157
+ get '/'
158
+ assert_caught_and_not_sent
159
+ end
160
+
161
+ def not_deliver_notices_from_actions_that_dont_raise
162
+ @app = AirbrakeTestController.action(:hello)
163
+ get '/'
164
+ assert_caught_and_not_sent
165
+ assert_equal 'hello', response.body
166
+ end
167
+
168
+ def not_deliver_ignored_exceptions_raised_by_actions
169
+ @app = AirbrakeTestController.action(:boom)
170
+ ignore(RuntimeError)
171
+ get '/'
172
+ assert_caught_and_not_sent
173
+ end
152
174
 
153
- should "not deliver notices from exceptions in development environments" do
154
- Airbrake.configuration.development_environments = ["test"]
155
- Airbrake.configuration.environment_name = "test"
156
- @app = AirbrakeTestController.action(:boom)
157
- get '/'
158
- assert_caught_and_not_sent
175
+ def deliver_ignored_exception_raised_manually
176
+ @app = AirbrakeTestController.action(:manual_airbrake)
177
+ ignore(RuntimeError)
178
+ get '/'
179
+ assert_caught_and_sent
159
180
  end
160
181
 
161
- should "not deliver notices from actions that don't raise" do
162
- @app = AirbrakeTestController.action(:hello)
163
- get '/'
164
- assert_caught_and_not_sent
165
- assert_equal 'hello', response.body
166
- end
167
-
168
- should "not deliver ignored exceptions raised by actions" do
169
- @app = AirbrakeTestController.action(:boom)
170
- ignore(RuntimeError)
171
- get '/'
172
- assert_caught_and_not_sent
173
- end
174
-
175
- should "deliver ignored exception raised manually" do
176
- @app = AirbrakeTestController.action(:manual_airbrake)
177
- ignore(RuntimeError)
178
- get '/'
179
- assert_caught_and_sent
180
- end
181
-
182
- should "not deliver manually sent notices in local requests" do
183
- AirbrakeTestController.local = true
184
- @app = AirbrakeTestController.action(:manual_airbrake)
185
- get '/'
186
- assert_caught_and_not_sent
187
- AirbrakeTestController.local = false
188
- end
189
-
190
- should "not create actions from Airbrake methods" do
191
- Airbrake::Rails::ControllerMethods.instance_methods.each do |method|
192
- assert !(AirbrakeTestController.new.action_methods.include?(method))
193
- end
194
- end
195
-
196
- should "ignore exceptions when user agent is being ignored by regular expression" do
197
- Airbrake.configuration.ignore_user_agent_only = [/Ignored/]
198
- @app = AirbrakeTestController.action(:boom)
199
- get "/", {}, {"HTTP_USER_AGENT" => "ShouldBeIgnored"}
200
- assert_caught_and_not_sent
201
- end
202
-
203
- should "ignore exceptions when user agent is being ignored by string" do
204
- Airbrake.configuration.ignore_user_agent_only = ['IgnoredUserAgent']
205
- @app = AirbrakeTestController.action(:boom)
206
- get "/", {}, {"HTTP_USER_AGENT" => "IgnoredUserAgent"}
207
- assert_caught_and_not_sent
208
- end
209
-
210
- should "not ignore exceptions when user agent is not being ignored" do
211
- Airbrake.configuration.ignore_user_agent_only = ['IgnoredUserAgent']
212
- @app = AirbrakeTestController.action(:boom)
213
- get "/", {}, {"HTTP_USER_AGENT" => "NonIgnoredAgent"}
214
- assert_caught_and_sent
215
- end
216
-
217
- should "send session data for manual notifications" do
218
- @app = AirbrakeTestController.action(:manual_airbrake)
219
- data = { 'one' => 'two' }
220
- get "/", :session => data
221
- assert_sent_hash data, "/notice/request/session"
222
- end
223
-
224
- should "send request data for manual notification" do
225
- params = { 'controller' => "airbrake_test", 'action' => "index" }
226
- @app = AirbrakeTestController.action(:manual_airbrake)
227
- get "/", params
228
- assert_sent_request_info_for @request
229
- end
230
-
231
- should "send request data for manual notification with non-standard port" do
232
- params = { 'controller' => "airbrake_test", 'action' => "index" }
233
- @app = AirbrakeTestController.action(:manual_airbrake)
234
- get "/", params, {"SERVER_PORT" => 81}
235
- assert_sent_request_info_for @request
182
+ def not_deliver_manually_sent_notices_in_local_requests
183
+ AirbrakeTestController.local = true
184
+ @app = AirbrakeTestController.action(:manual_airbrake)
185
+ get '/'
186
+ assert_caught_and_not_sent
187
+ AirbrakeTestController.local = false
236
188
  end
237
189
 
238
- should "send request data for automatic notification" do
239
- params = { 'controller' => "airbrake_test", 'action' => "index" }
240
- @app = AirbrakeTestController.action(:boom)
241
- get "/", params
242
- assert_sent_request_info_for @request
243
- end
244
-
245
- should "send request data for automatic notification with non-standard port" do
246
- params = { 'controller' => "airbrake_test", 'action' => "index" }
247
- @app = AirbrakeTestController.action(:boom)
248
- get "/", params, {"SERVER_PORT" => 81}
249
- assert_sent_request_info_for @request
250
- assert_sent_element 81, "/notice/request/cgi-data/var[@key = 'SERVER_PORT']"
251
- end
252
-
253
- # should "call session.to_hash if available" do
254
- # hash_data = {:key => :value}
255
-
256
- # session = ActionController::TestSession.new
257
- # ActionController::TestSession.stubs(:new).returns(session)
258
- # session.stubs(:to_hash).returns(hash_data)
259
-
260
- # Airbrake.configuration.environment_name = "production"
261
-
262
- # @app = AirbrakeTestController.action(:boom)
263
- # get '/'
264
-
265
- # assert_received(session, :to_hash)
266
- # assert_received(session, :data) { |expect| expect.never }
267
- # assert_caught_and_sent
268
- # end
269
-
270
- # should "call session.data if session.to_hash is undefined" do
271
- # hash_data = {:key => :value}
272
-
273
- # session = ActionController::TestSession.new
274
- # ActionController::TestSession.stubs(:new).returns(session)
275
- # session.stubs(:data).returns(hash_data)
276
- # if session.respond_to?(:to_hash)
277
- # class << session
278
- # undef to_hash
279
- # end
280
- # end
281
-
282
- # Airbrake.configuration.environment_name = "production"
283
-
284
- # @app = AirbrakeTestController.action(:boom)
285
- # get '/'
286
-
287
- # assert_received(session, :to_hash) { |expect| expect.never }
288
- # assert_received(session, :data) { |expect| expect.at_least_once }
289
- # assert_caught_and_sent
290
- # end
190
+ def not_create_actions_from_airbrake_methods
191
+ Airbrake::Rails::ControllerMethods.instance_methods.each do |method|
192
+ assert !(AirbrakeTestController.new.action_methods.include?(method))
193
+ end
194
+ end
195
+
196
+ def ignore_exceptions_when_user_agent_is_being_ignored_by_regular_expression
197
+ Airbrake.configuration.ignore_user_agent_only = [/Ignored/]
198
+ @app = AirbrakeTestController.action(:boom)
199
+ get "/", {}, {"HTTP_USER_AGENT" => "ShouldBeIgnored"}
200
+ assert_caught_and_not_sent
201
+ end
202
+
203
+ def ignore_exceptions_when_user_agent_is_being_ignored_by_string
204
+ Airbrake.configuration.ignore_user_agent_only = ['IgnoredUserAgent']
205
+ @app = AirbrakeTestController.action(:boom)
206
+ get "/", {}, {"HTTP_USER_AGENT" => "IgnoredUserAgent"}
207
+ assert_caught_and_not_sent
208
+ end
209
+
210
+ def not_ignore_exceptions_when_user_agent_is_not_being_ignored
211
+ Airbrake.configuration.ignore_user_agent_only = ['IgnoredUserAgent']
212
+ @app = AirbrakeTestController.action(:boom)
213
+ get "/", {}, {"HTTP_USER_AGENT" => "NonIgnoredAgent"}
214
+ assert_caught_and_sent
215
+ end
216
+
217
+ def send_session_data_for_manual_notifications
218
+ @app = AirbrakeTestController.action(:manual_airbrake)
219
+ data = { 'one' => 'two' }
220
+ get "/", :session => data
221
+ assert_sent_hash data, "/notice/request/session"
222
+ end
223
+
224
+ def send_request_data_for_manual_notification
225
+ params = { 'controller' => "airbrake_test", 'action' => "index" }
226
+ @app = AirbrakeTestController.action(:manual_airbrake)
227
+ get "/", params
228
+ assert_sent_request_info_for @request
229
+ end
230
+
231
+ def send_request_data_for_manual_notification_with_non_standard_port
232
+ params = { 'controller' => "airbrake_test", 'action' => "index" }
233
+ @app = AirbrakeTestController.action(:manual_airbrake)
234
+ get "/", params, {"SERVER_PORT" => 81}
235
+ assert_sent_request_info_for @request
236
+ end
237
+
238
+ def send_request_data_for_automatic_notification
239
+ params = { 'controller' => "airbrake_test", 'action' => "index" }
240
+ @app = AirbrakeTestController.action(:boom)
241
+ get "/", params
242
+ assert_sent_request_info_for @request
243
+ end
244
+
245
+ def send_request_data_for_automatic_notification_with_non_standard_port
246
+ params = { 'controller' => "airbrake_test", 'action' => "index" }
247
+ @app = AirbrakeTestController.action(:boom)
248
+ get "/", params, {"SERVER_PORT" => 81}
249
+ assert_sent_request_info_for @request
250
+ assert_sent_element 81, "/notice/request/cgi-data/var[@key = 'SERVER_PORT']"
251
+ end
291
252
  end
@@ -5,7 +5,6 @@ $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
5
5
 
6
6
  require 'thread'
7
7
 
8
- require 'shoulda'
9
8
  require 'mocha'
10
9
 
11
10
  require 'abstract_controller'
@@ -24,6 +23,9 @@ require 'json-schema'
24
23
 
25
24
  require "airbrake"
26
25
 
26
+ require "shoulda-matchers"
27
+ require "shoulda-context"
28
+
27
29
  begin require 'redgreen'; rescue LoadError; end
28
30
 
29
31
  # Show backtraces for deprecated behavior for quicker cleanup.
@@ -47,77 +49,76 @@ class RoutedRackApp
47
49
  end
48
50
  end
49
51
 
50
- class ActionDispatch::IntegrationTest < ActiveSupport::TestCase
51
- setup do
52
- @routes = SharedTestRoutes
53
- end
54
- end
55
-
56
- class ActionController::IntegrationTest < ActiveSupport::TestCase
57
- def self.build_app(routes = nil)
58
- RoutedRackApp.new(routes || ActionDispatch::Routing::RouteSet.new) do |middleware|
59
- middleware.use "ActionDispatch::Callbacks"
60
- middleware.use "ActionDispatch::ParamsParser"
61
- middleware.use "ActionDispatch::Cookies"
62
- middleware.use "ActionDispatch::Flash"
63
- middleware.use "ActionDispatch::Head"
64
- yield(middleware) if block_given?
52
+ unless defined?(ActionDispatch::IntegrationTest)
53
+ class ActionController::IntegrationTest < ActiveSupport::TestCase
54
+ def self.build_app(routes = nil)
55
+ RoutedRackApp.new(routes || ActionDispatch::Routing::RouteSet.new) do |middleware|
56
+ yield(middleware) if block_given?
57
+ end
65
58
  end
66
- end
67
59
 
68
- self.app = build_app
60
+ self.app = build_app
69
61
 
70
- # Stub Rails dispatcher so it does not get controller references and
71
- # simply return the controller#action as Rack::Body.
72
- class StubDispatcher < ::ActionDispatch::Routing::RouteSet::Dispatcher
73
- protected
74
- def controller_reference(controller_param)
75
- controller_param
76
- end
62
+ # Stub Rails dispatcher so it does not get controller references and
63
+ # simply return the controller#action as Rack::Body.
64
+ class StubDispatcher < ::ActionDispatch::Routing::RouteSet::Dispatcher
65
+ protected
66
+ def controller_reference(controller_param)
67
+ controller_param
68
+ end
77
69
 
78
- def dispatch(controller, action, env)
79
- [200, {'Content-Type' => 'text/html'}, ["#{controller}##{action}"]]
70
+ def dispatch(controller, action, env)
71
+ [200, {'Content-Type' => 'text/html'}, ["#{controller}##{action}"]]
72
+ end
80
73
  end
81
- end
82
74
 
83
- def self.stub_controllers
84
- old_dispatcher = ActionDispatch::Routing::RouteSet::Dispatcher
85
- ActionDispatch::Routing::RouteSet.module_eval { remove_const :Dispatcher }
86
- ActionDispatch::Routing::RouteSet.module_eval { const_set :Dispatcher, StubDispatcher }
87
- yield ActionDispatch::Routing::RouteSet.new
88
- ensure
89
- ActionDispatch::Routing::RouteSet.module_eval { remove_const :Dispatcher }
90
- ActionDispatch::Routing::RouteSet.module_eval { const_set :Dispatcher, old_dispatcher }
91
- end
75
+ def self.stub_controllers
76
+ old_dispatcher = ActionDispatch::Routing::RouteSet::Dispatcher
77
+ ActionDispatch::Routing::RouteSet.module_eval { remove_const :Dispatcher }
78
+ ActionDispatch::Routing::RouteSet.module_eval { const_set :Dispatcher, StubDispatcher }
79
+ yield ActionDispatch::Routing::RouteSet.new
80
+ ensure
81
+ ActionDispatch::Routing::RouteSet.module_eval { remove_const :Dispatcher }
82
+ ActionDispatch::Routing::RouteSet.module_eval { const_set :Dispatcher, old_dispatcher }
83
+ end
92
84
 
93
- def with_routing(&block)
94
- temporary_routes = ActionDispatch::Routing::RouteSet.new
95
- old_app, self.class.app = self.class.app, self.class.build_app(temporary_routes)
96
- old_routes = SharedTestRoutes
97
- silence_warnings { Object.const_set(:SharedTestRoutes, temporary_routes) }
85
+ def with_routing(&block)
86
+ temporary_routes = ActionDispatch::Routing::RouteSet.new
87
+ old_app, self.class.app = self.class.app, self.class.build_app(temporary_routes)
88
+ old_routes = SharedTestRoutes
89
+ silence_warnings { Object.const_set(:SharedTestRoutes, temporary_routes) }
98
90
 
99
- yield temporary_routes
100
- ensure
101
- self.class.app = old_app
102
- silence_warnings { Object.const_set(:SharedTestRoutes, old_routes) }
103
- end
91
+ yield temporary_routes
92
+ ensure
93
+ self.class.app = old_app
94
+ silence_warnings { Object.const_set(:SharedTestRoutes, old_routes) }
95
+ end
104
96
 
105
- def with_autoload_path(path)
106
- path = File.join(File.dirname(__FILE__), "fixtures", path)
107
- if ActiveSupport::Dependencies.autoload_paths.include?(path)
108
- yield
109
- else
110
- begin
111
- ActiveSupport::Dependencies.autoload_paths << path
97
+ def with_autoload_path(path)
98
+ path = File.join(File.dirname(__FILE__), "fixtures", path)
99
+ if ActiveSupport::Dependencies.autoload_paths.include?(path)
112
100
  yield
113
- ensure
114
- ActiveSupport::Dependencies.autoload_paths.reject! {|p| p == path}
115
- ActiveSupport::Dependencies.clear
101
+ else
102
+ begin
103
+ ActiveSupport::Dependencies.autoload_paths << path
104
+ yield
105
+ ensure
106
+ ActiveSupport::Dependencies.autoload_paths.reject! {|p| p == path}
107
+ ActiveSupport::Dependencies.clear
108
+ end
116
109
  end
117
110
  end
118
111
  end
119
112
  end
120
113
 
114
+ class ActionDispatch::IntegrationTest < ActiveSupport::TestCase
115
+ setup do
116
+ @routes = SharedTestRoutes
117
+ end
118
+ end
119
+
120
+
121
+
121
122
  module ActionController
122
123
  class Base
123
124
  include ActionController::Testing
@@ -1,5 +1,8 @@
1
1
  require File.expand_path '../helper', __FILE__
2
2
 
3
+ XSD_SCHEMA_PATH = "http://airbrake.io/airbrake_#{Airbrake::API_VERSION.tr(".","_")}.xsd"
4
+ FakeWeb.allow_net_connect = %r{#{XSD_SCHEMA_PATH}}
5
+
3
6
  class NoticeTest < Test::Unit::TestCase
4
7
 
5
8
  include DefinesConstants
@@ -61,8 +64,8 @@ class NoticeTest < Test::Unit::TestCase
61
64
  end
62
65
 
63
66
  def assert_valid_notice_document(document)
64
- xsd_path = File.expand_path(File.join(File.dirname(__FILE__),"..", "resources", "airbrake_2_4.xsd"))
65
- schema = Nokogiri::XML::Schema.new(IO.read(xsd_path))
67
+ xsd_path = URI(XSD_SCHEMA_PATH)
68
+ schema = Nokogiri::XML::Schema.new(Net::HTTP.get(xsd_path))
66
69
  errors = schema.validate(document)
67
70
  assert errors.empty?, errors.collect{|e| e.message }.join
68
71
  end
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.11
4
+ version: 3.1.12
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-11 00:00:00.000000000 Z
12
+ date: 2013-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder
@@ -156,23 +156,23 @@ dependencies:
156
156
  - !ruby/object:Gem::Version
157
157
  version: 1.3.0
158
158
  - !ruby/object:Gem::Dependency
159
- name: shoulda
159
+ name: capistrano
160
160
  requirement: !ruby/object:Gem::Requirement
161
161
  none: false
162
162
  requirements:
163
- - - ~>
163
+ - - ! '>='
164
164
  - !ruby/object:Gem::Version
165
- version: 2.11.3
165
+ version: '0'
166
166
  type: :development
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  none: false
170
170
  requirements:
171
- - - ~>
171
+ - - ! '>='
172
172
  - !ruby/object:Gem::Version
173
- version: 2.11.3
173
+ version: '0'
174
174
  - !ruby/object:Gem::Dependency
175
- name: capistrano
175
+ name: aruba
176
176
  requirement: !ruby/object:Gem::Requirement
177
177
  none: false
178
178
  requirements:
@@ -188,7 +188,7 @@ dependencies:
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0'
190
190
  - !ruby/object:Gem::Dependency
191
- name: aruba
191
+ name: appraisal
192
192
  requirement: !ruby/object:Gem::Requirement
193
193
  none: false
194
194
  requirements:
@@ -204,7 +204,7 @@ dependencies:
204
204
  - !ruby/object:Gem::Version
205
205
  version: '0'
206
206
  - !ruby/object:Gem::Dependency
207
- name: appraisal
207
+ name: rspec-rails
208
208
  requirement: !ruby/object:Gem::Requirement
209
209
  none: false
210
210
  requirements:
@@ -220,7 +220,7 @@ dependencies:
220
220
  - !ruby/object:Gem::Version
221
221
  version: '0'
222
222
  - !ruby/object:Gem::Dependency
223
- name: rspec-rails
223
+ name: girl_friday
224
224
  requirement: !ruby/object:Gem::Requirement
225
225
  none: false
226
226
  requirements:
@@ -236,7 +236,7 @@ dependencies:
236
236
  - !ruby/object:Gem::Version
237
237
  version: '0'
238
238
  - !ruby/object:Gem::Dependency
239
- name: girl_friday
239
+ name: json-schema
240
240
  requirement: !ruby/object:Gem::Requirement
241
241
  none: false
242
242
  requirements:
@@ -252,7 +252,23 @@ dependencies:
252
252
  - !ruby/object:Gem::Version
253
253
  version: '0'
254
254
  - !ruby/object:Gem::Dependency
255
- name: json-schema
255
+ name: shoulda-matchers
256
+ requirement: !ruby/object:Gem::Requirement
257
+ none: false
258
+ requirements:
259
+ - - ! '>='
260
+ - !ruby/object:Gem::Version
261
+ version: '0'
262
+ type: :development
263
+ prerelease: false
264
+ version_requirements: !ruby/object:Gem::Requirement
265
+ none: false
266
+ requirements:
267
+ - - ! '>='
268
+ - !ruby/object:Gem::Version
269
+ version: '0'
270
+ - !ruby/object:Gem::Dependency
271
+ name: shoulda-context
256
272
  requirement: !ruby/object:Gem::Requirement
257
273
  none: false
258
274
  requirements:
@@ -310,12 +326,11 @@ files:
310
326
  - lib/airbrake/sinatra.rb
311
327
  - lib/airbrake/response.rb
312
328
  - lib/rails/generators/airbrake/airbrake_generator.rb
313
- - lib/templates/javascript_notifier.erb
329
+ - lib/templates/javascript_notifier
314
330
  - lib/templates/rescue.erb
315
331
  - lib/airbrake_tasks.rb
316
332
  - rails/init.rb
317
333
  - resources/ca-bundle.crt
318
- - resources/airbrake_2_4.xsd
319
334
  - resources/README.md
320
335
  - resources/airbrake_3_0.json
321
336
  - resources/notice.xml
@@ -1,89 +0,0 @@
1
- <?xml version="1.0"?>
2
- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
3
-
4
- <xs:element name="notice">
5
- <xs:complexType>
6
- <xs:all>
7
- <xs:element name="api-key" type="xs:string"/>
8
- <xs:element name="notifier" type="notifier"/>
9
- <xs:element name="error" type="error"/>
10
- <xs:element name="request" type="request" minOccurs="0"/>
11
- <xs:element name="server-environment" type="serverEnvironment"/>
12
- <xs:element name="current-user" type="current-user" minOccurs="0"/>
13
- <xs:element name="framework" type="xs:string" minOccurs="0"/>
14
- </xs:all>
15
- <xs:attribute name="version" type="xs:string" use="required"/>
16
- </xs:complexType>
17
- </xs:element>
18
-
19
- <xs:complexType name="notifier">
20
- <xs:all>
21
- <xs:element name="name" type="xs:string"/>
22
- <xs:element name="version" type="xs:string"/>
23
- <xs:element name="url" type="xs:string"/>
24
- </xs:all>
25
- </xs:complexType>
26
-
27
- <xs:complexType name="error">
28
- <xs:all>
29
- <xs:element name="class" type="xs:string"/>
30
- <xs:element name="message" type="xs:string" minOccurs="0"/>
31
- <xs:element name="backtrace" type="backtrace"/>
32
- </xs:all>
33
- </xs:complexType>
34
-
35
- <xs:complexType name="backtrace">
36
- <xs:sequence>
37
- <xs:element name="line" maxOccurs="unbounded" minOccurs="0">
38
- <xs:complexType>
39
- <xs:attribute name="file" type="xs:string" use="required"/>
40
- <xs:attribute name="number" type="xs:string" use="required"/>
41
- <xs:attribute name="method" type="xs:string" use="optional"/>
42
- </xs:complexType>
43
- </xs:element>
44
- </xs:sequence>
45
- </xs:complexType>
46
-
47
- <xs:complexType name="request">
48
- <xs:all>
49
- <xs:element name="url" type="xs:string"/>
50
- <xs:element name="component" type="xs:string"/>
51
- <xs:element name="action" type="xs:string" minOccurs="0"/>
52
- <xs:element name="params" type="varList" minOccurs="0"/>
53
- <xs:element name="session" type="varList" minOccurs="0"/>
54
- <xs:element name="cgi-data" type="varList" minOccurs="0"/>
55
- </xs:all>
56
- </xs:complexType>
57
-
58
- <xs:complexType name="varList">
59
- <xs:sequence>
60
- <xs:element name="var" type="var" maxOccurs="unbounded"/>
61
- </xs:sequence>
62
- </xs:complexType>
63
-
64
- <xs:complexType name="var" mixed="true">
65
- <xs:sequence>
66
- <xs:element name="var" type="var" minOccurs="0" maxOccurs="unbounded"/>
67
- </xs:sequence>
68
- <xs:attribute name="key" type="xs:string" use="required"/>
69
- </xs:complexType>
70
-
71
- <xs:complexType name="serverEnvironment">
72
- <xs:sequence>
73
- <xs:element name="project-root" type="xs:string" minOccurs="0"/>
74
- <xs:element name="environment-name" type="xs:string"/>
75
- <xs:element name="app-version" type="xs:string" minOccurs="0"/>
76
- <xs:element name="hostname" type="xs:string" minOccurs="0"/>
77
- </xs:sequence>
78
- </xs:complexType>
79
-
80
- <xs:complexType name="current-user">
81
- <xs:all>
82
- <xs:element name="id" type="xs:string"/>
83
- <xs:element name="name" type="xs:string" minOccurs="0"/>
84
- <xs:element name="email" type="xs:string" minOccurs="0"/>
85
- <xs:element name="username" type="xs:string" minOccurs="0"/>
86
- </xs:all>
87
- </xs:complexType>
88
-
89
- </xs:schema>