airbrake 3.1.12 → 3.1.13

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.
Files changed (45) hide show
  1. data/CHANGELOG +61 -0
  2. data/README.md +36 -17
  3. data/Rakefile +14 -8
  4. data/TESTED_AGAINST +1 -0
  5. data/airbrake.gemspec +3 -3
  6. data/features/metal.feature +1 -1
  7. data/features/rails.feature +1 -0
  8. data/features/rake.feature +4 -0
  9. data/features/sinatra.feature +72 -1
  10. data/features/support/rake/Rakefile +14 -4
  11. data/generators/airbrake/airbrake_generator.rb +5 -5
  12. data/lib/airbrake.rb +2 -9
  13. data/lib/airbrake/backtrace.rb +8 -13
  14. data/lib/airbrake/capistrano.rb +58 -2
  15. data/lib/airbrake/cli/runner.rb +1 -0
  16. data/lib/airbrake/configuration.rb +31 -11
  17. data/lib/airbrake/notice.rb +52 -61
  18. data/lib/airbrake/rails/controller_methods.rb +7 -3
  19. data/lib/airbrake/rails/javascript_notifier.rb +56 -31
  20. data/lib/airbrake/rake_handler.rb +3 -2
  21. data/lib/airbrake/response.rb +6 -8
  22. data/lib/airbrake/sender.rb +1 -1
  23. data/lib/airbrake/sinatra.rb +9 -2
  24. data/lib/airbrake/user_informer.rb +1 -1
  25. data/lib/airbrake/version.rb +1 -1
  26. data/lib/airbrake_tasks.rb +2 -2
  27. data/lib/rails/generators/airbrake/airbrake_generator.rb +5 -5
  28. data/lib/templates/javascript_notifier_configuration +12 -0
  29. data/lib/templates/javascript_notifier_loader +6 -0
  30. data/resources/notice.xml +2 -1
  31. data/test/airbrake_tasks_test.rb +2 -2
  32. data/test/backtrace_test.rb +19 -0
  33. data/test/capistrano_test.rb +9 -1
  34. data/test/configuration_test.rb +49 -2
  35. data/test/controller_methods_test.rb +22 -0
  36. data/test/helper.rb +29 -155
  37. data/test/integration.rb +15 -0
  38. data/test/{catcher_test.rb → integration/catcher_test.rb} +130 -19
  39. data/test/{javascript_notifier_test.rb → integration/javascript_notifier_test.rb} +0 -1
  40. data/test/logger_test.rb +11 -11
  41. data/test/notice_test.rb +8 -2
  42. data/test/notifier_test.rb +6 -6
  43. data/test/sender_test.rb +1 -1
  44. metadata +34 -31
  45. data/lib/templates/javascript_notifier +0 -20
data/CHANGELOG CHANGED
@@ -1,3 +1,63 @@
1
+ Version 3.1.13 - 2013-08-20 09:39:41 +0200
2
+ ===============================================================================
3
+
4
+ Anton Minin (1):
5
+ Fix notice crash on empty cgi_data
6
+
7
+ Cedric Brancourt (2):
8
+ fixes #231 When no session in controller , airbrake_session_data returns {:session => "no session found"}
9
+ fixes airbrake/airbrake#233 duplicate cgi_data in Notice params
10
+
11
+ Chris Gunther (2):
12
+ Coerce user attributes to strings before checking that they are valid.
13
+ Reject invalid user attributes on assignment
14
+
15
+ Hongli Lai (Phusion) (1):
16
+ Add support for SSL in the command line tool.
17
+
18
+ Hrvoje Šimić (22):
19
+ better explanation of ignored environments and classes
20
+ add test for warnings about user attributes
21
+ remove unnecessary active record requirements
22
+ remove platform checks from nil logger initialization
23
+ update bourne dependency to fix test-running issues with ruby 2.0.0
24
+ test against ruby 2.0.0 on a CI server
25
+ remove mocha deprecation warnings
26
+ be more careful when reading sinatra environment name
27
+ wrap the js configuration in try-catch
28
+ ignore Gemfile.lock
29
+ lock json-schema to 1.0.12
30
+ add a scenario for ignoring rake exceptions [#223]
31
+ get rid of activesupport once and for all
32
+ fully support Rails 4.0
33
+ stop using appraisals for unit tests
34
+ fix formatting of airbrake_session_data
35
+ fix test for no session controller [#232]
36
+ include actionpack and activesupport in gemspec for tests
37
+ cleaning up tests
38
+ cleaning the codebase from warnings issued in ruby verbose mode
39
+ remove private writers and use instance variables to remove warnings
40
+ fixing changeling's version sorting
41
+
42
+ Jason Petersen (1):
43
+ Escape user name in Airbrake notify command
44
+
45
+ Konstantin Zub (1):
46
+ return environment_info unless environment_name
47
+
48
+ Kris Kemper (1):
49
+ Allow backtrace to be a String
50
+
51
+ Nathan Broadbent (1):
52
+ Use a separate (blank) array of ignored exceptions for Rake tasks
53
+
54
+ Subhash Chandra (1):
55
+ split javascript notifier into loader and configuration
56
+
57
+ Tony Spore (1):
58
+ use 'bundle exec' in capistrano task
59
+
60
+
1
61
  Version 3.1.12 - 2013-04-29 18:48:40 +0200
2
62
  ===============================================================================
3
63
 
@@ -1165,3 +1225,4 @@ Nick Quaranto (3):
1165
1225
 
1166
1226
 
1167
1227
 
1228
+
data/README.md CHANGED
@@ -27,19 +27,8 @@ Then from your project's RAILS_ROOT, and in your development environment, run:
27
27
  bundle install
28
28
  rails generate airbrake --api-key your_key_here
29
29
 
30
- That's it!
31
-
32
30
  The generator creates a file under `config/initializers/airbrake.rb` configuring Airbrake with your API key. This file should be checked into your version control system so that it is deployed to your staging and production environments.
33
31
 
34
- The default behaviour of the gem is to only operate in Rails environments that are NOT **development**, **test** & **cucumber**.
35
-
36
- You can change this by altering this array:
37
-
38
- config.development_environments = ["development", "test", "cucumber", "custom"]
39
-
40
- Set it to empty array and it will report errors on all environments.
41
-
42
-
43
32
  ### Rails 2.x
44
33
 
45
34
  Add the airbrake gem to your app. In config/environment.rb:
@@ -61,6 +50,34 @@ every server you deploy to has the gem installed or your application won't start
61
50
 
62
51
  The generator creates a file under `config/initializers/airbrake.rb` configuring Airbrake with your API key. This file should be checked into your version control system so that it is deployed to your staging and production environments.
63
52
 
53
+ Ignored exceptions
54
+ ------------------------
55
+
56
+ Exceptions raised from Rails environments named **development**, **test** or **cucumber** will be ignored by default.
57
+
58
+ You can clear the list of ignored environments with this setting:
59
+
60
+ config.development_environments = []
61
+
62
+ List of ignored exception classes includes:
63
+
64
+ ActiveRecord::RecordNotFound
65
+ ActionController::RoutingError
66
+ ActionController::InvalidAuthenticityToken
67
+ CGI::Session::CookieStore::TamperedWithCookie
68
+ ActionController::UnknownHttpMethod
69
+ ActionController::UnknownAction
70
+ AbstractController::ActionNotFound
71
+ Mongoid::Errors::DocumentNotFound
72
+
73
+ You can alter this list with
74
+
75
+ config.ignore_only = []
76
+
77
+ which will cause none of the exception classes to be ignored.
78
+
79
+ Check the [wiki](https://github.com/airbrake/airbrake/wiki/Customizing-your-airbrake.rb) for more customization options.
80
+
64
81
  Supported frameworks
65
82
  ------------------------
66
83
 
@@ -76,18 +93,20 @@ https://github.com/airbrake/airbrake/wiki
76
93
  Development
77
94
  -----------
78
95
 
79
- We use [Appraisals](https://github.com/thoughtbot/appraisal) to run the tests.
80
-
81
- To run the test suite on your machine, you need to run the following commands:
96
+ For running unit tests, you should run
82
97
 
83
98
  bundle
84
- bundle exec rake appraisal:install
99
+ bundle exec rake test
85
100
 
86
- After this, you're ready to run the suite with:
101
+ If you wish to run the entire suite, which checks the different framework
102
+ integrations with cucumber, you should run the following commands
87
103
 
104
+ bundle
105
+ bundle exec rake appraisal:install
88
106
  bundle exec rake
89
107
 
90
- This will include cucumber features we use to fully test the integration.
108
+ We use [Appraisals](https://github.com/thoughtbot/appraisal) to run the integration
109
+ tests.
91
110
 
92
111
  Maintainers
93
112
  -----------
data/Rakefile CHANGED
@@ -13,17 +13,24 @@ end
13
13
  require './lib/airbrake/version'
14
14
 
15
15
  task :default do
16
- exec 'rake appraisal:rails-3.0 test '\
17
- '&& rake appraisal:rails-3.1 test '\
18
- '&& rake appraisal:rails-3.2 test '\
19
- '&& rake appraisal:rails-4.0 test '\
20
- '&& rake appraisal cucumber'\
16
+ exec 'rake test'\
17
+ '&& rake appraisal:rails-3.2 integration_test'\
18
+ '&& rake appraisal:rails-3.1 integration_test'\
19
+ '&& rake appraisal:rails-3.0 integration_test'\
20
+ '&& rake appraisal cucumber'
21
21
  end
22
22
 
23
23
  desc 'Test the airbrake gem.'
24
24
  Rake::TestTask.new(:test) do |t|
25
25
  t.libs << 'lib'
26
- t.pattern = 'test/**/*_test.rb'
26
+ t.pattern = 'test/*_test.rb'
27
+ t.verbose = true
28
+ end
29
+
30
+ desc "Test the integration of airbrake gem with Rails."
31
+ Rake::TestTask.new(:integration_test) do |t|
32
+ t.libs << 'lib'
33
+ t.pattern = 'test/integration.rb'
27
34
  t.verbose = true
28
35
  end
29
36
 
@@ -75,7 +82,7 @@ EOF
75
82
  Version #{version} - #{Time.now}
76
83
  ===============================================================================
77
84
 
78
- #{`git log $(git tag | grep -v rc | tail -1)..HEAD | git shortlog`}
85
+ #{`git log $(git tag | grep -v rc | sort --version-sort | tail -1)..HEAD | git shortlog`}
79
86
  #{old}
80
87
  EOF
81
88
  end
@@ -144,4 +151,3 @@ Cucumber::Rake::Task.new(:cucumber) do |t|
144
151
  t.fork = true
145
152
  t.cucumber_opts = cucumber_opts
146
153
  end
147
-
@@ -1,6 +1,7 @@
1
1
  Rails 3.0.20
2
2
  Rails 3.1.12
3
3
  Rails 3.2.13
4
+ Rails 4.0.0
4
5
  Sinatra 1.3.3
5
6
  Rack 1.4.3
6
7
  Rake 10.0.3
@@ -14,23 +14,23 @@ Gem::Specification.new do |s|
14
14
  s.test_files = Dir.glob("{test,spec,features}/**/*")
15
15
 
16
16
  s.add_runtime_dependency("builder")
17
- s.add_runtime_dependency("activesupport")
18
17
  s.add_runtime_dependency("json")
19
18
 
20
- s.add_development_dependency("bourne", ">= 1.0")
19
+ s.add_development_dependency("bourne", "~> 1.4.0")
21
20
  s.add_development_dependency("cucumber-rails","~> 1.1.1")
22
21
  s.add_development_dependency("fakeweb", "~> 1.3.0")
23
22
  s.add_development_dependency("nokogiri", "~> 1.5.0")
24
23
  s.add_development_dependency("rspec", "~> 2.6.0")
25
24
  s.add_development_dependency("sham_rack", "~> 1.3.0")
25
+ s.add_development_dependency("json-schema", "~> 1.0.12")
26
26
  s.add_development_dependency("capistrano")
27
27
  s.add_development_dependency("aruba")
28
28
  s.add_development_dependency("appraisal")
29
29
  s.add_development_dependency("rspec-rails")
30
30
  s.add_development_dependency("girl_friday")
31
- s.add_development_dependency("json-schema")
32
31
  s.add_development_dependency("shoulda-matchers")
33
32
  s.add_development_dependency("shoulda-context")
33
+ s.add_development_dependency("pry")
34
34
 
35
35
  s.authors = ["Airbrake"]
36
36
  s.email = %q{support@airbrake.io}
@@ -1,6 +1,6 @@
1
1
  Feature: Rescue errors in Rails middleware
2
2
  Background:
3
- Given I successfully run `rails new rails_root -O --without-gemfile`
3
+ Given I successfully run `rails new rails_root -O --skip-gemfile`
4
4
  And I cd to "rails_root"
5
5
  And I configure the notifier to use the following configuration lines:
6
6
  """
@@ -251,6 +251,7 @@ Feature: Install the Gem in a Rails application
251
251
  """
252
252
  And I run `rails runner config/boot.rb`
253
253
  Then I should see "Unsupported user attribute: 'shoe_size'"
254
+ And I should not see "Unsupported user attribute: 'id'"
254
255
 
255
256
  Scenario: It should log the notice when failure happens
256
257
  When Airbrake server is not responding
@@ -3,6 +3,10 @@ Feature: Use the Gem to catch errors in a Rake application
3
3
  Background:
4
4
  Given I've prepared the Rakefile
5
5
 
6
+ Scenario: Ignoring exceptions
7
+ When I run rake with airbrake ignored
8
+ Then Airbrake should not catch the exception
9
+
6
10
  Scenario: Catching exceptions in Rake
7
11
  When I run rake with airbrake
8
12
  Then Airbrake should catch the exception
@@ -25,7 +25,7 @@ Feature: Use the notifier in a Sinatra app
25
25
  """
26
26
  When I perform a Rack request to "http://example.com:123/test/index?param=value"
27
27
  Then I should receive a Airbrake notification
28
-
28
+
29
29
  Scenario: Catching environment name in modular Sinatra app
30
30
  Given the following Rack app:
31
31
  """
@@ -53,3 +53,74 @@ Feature: Use the notifier in a Sinatra app
53
53
  When I perform a Rack request to "http://example.com:123/test/index?param=value"
54
54
  Then I should receive a Airbrake notification
55
55
  And the output should contain "Env: production"
56
+
57
+ Scenario: Warnings when environment name wasn't determined automatically
58
+ Given the following Rack app:
59
+ """
60
+ require 'sinatra/base'
61
+ require 'airbrake'
62
+ require 'logger'
63
+
64
+ Airbrake.configure do |config|
65
+ config.api_key = 'my_api_key'
66
+ config.logger = Logger.new STDOUT
67
+ config.development_environments = []
68
+ end
69
+
70
+ class DummyMiddleware
71
+ def initialize(app)
72
+ @app = app
73
+ end
74
+
75
+ def call(env)
76
+ @app.call(env)
77
+ end
78
+ end
79
+
80
+ class FontaneApp < Sinatra::Base
81
+
82
+ use Airbrake::Sinatra
83
+
84
+ use DummyMiddleware
85
+
86
+ set :environment, :production
87
+
88
+ get "/test/index" do
89
+ raise "Sinatra has left the building"
90
+ end
91
+ end
92
+
93
+ app = FontaneApp
94
+ """
95
+ When I perform a Rack request to "http://example.com:123/test/index?param=value"
96
+ Then I should receive a Airbrake notification
97
+ And the output should contain "Please set your environment name manually"
98
+
99
+ Scenario: Give precendence to environment name that was first set
100
+ Given the following Rack app:
101
+ """
102
+ require 'sinatra/base'
103
+ require 'airbrake'
104
+ require 'logger'
105
+
106
+ Airbrake.configure do |config|
107
+ config.api_key = 'my_api_key'
108
+ config.logger = Logger.new STDOUT
109
+ config.environment_name = "staging"
110
+ end
111
+
112
+ class FontaneApp < Sinatra::Base
113
+ use Airbrake::Sinatra
114
+
115
+ set :environment, :production
116
+
117
+ get "/test/index" do
118
+ raise "Sinatra has left the building"
119
+ end
120
+ end
121
+
122
+ app = FontaneApp
123
+ """
124
+ When I perform a Rack request to "http://example.com:123/test/index?param=value"
125
+ Then I should receive a Airbrake notification
126
+ And the output should contain "Env: staging"
@@ -5,7 +5,10 @@ require 'rubygems'
5
5
  require 'airbrake'
6
6
  require 'airbrake/rake_handler'
7
7
 
8
+ class IgnoredException < StandardError; end
9
+
8
10
  Airbrake.configure do |c|
11
+ c.ignore_rake_only = ["IgnoredException"]
9
12
  end
10
13
 
11
14
  # Should catch exception
@@ -22,6 +25,13 @@ task :airbrake_disabled do
22
25
  raise_exception
23
26
  end
24
27
 
28
+ # Should ignore the exception
29
+ task :airbrake_ignored do
30
+ Airbrake.configuration.rescue_rake_exceptions = true
31
+ stub_tty_output(true)
32
+ raise_exception(IgnoredException)
33
+ end
34
+
25
35
  # Should not catch exception as tty_output is true
26
36
  task :airbrake_autodetect_from_terminal do
27
37
  Airbrake.configuration.rescue_rake_exceptions = nil
@@ -44,8 +54,8 @@ task :airbrake_not_yet_configured do
44
54
  end
45
55
 
46
56
  module Airbrake
47
- def self.notify_or_ignore(*args)
48
- $stderr.puts "[airbrake] #{args[1][:component]}"
57
+ def self.send_notice(notice)
58
+ $stderr.puts "[airbrake] #{notice.component}"
49
59
  end
50
60
  end
51
61
 
@@ -62,6 +72,6 @@ def stub_tty_output(value)
62
72
  end
63
73
  end
64
74
 
65
- def raise_exception
66
- raise 'TEST'
75
+ def raise_exception(exception_class = StandardError)
76
+ raise exception_class.new('TEST')
67
77
  end
@@ -49,14 +49,14 @@ class AirbrakeGenerator < Rails::Generator::Base
49
49
  def determine_api_key
50
50
  puts "Attempting to determine your API Key from Heroku..."
51
51
  ENV['HOPTOAD_API_KEY'] = heroku_api_key
52
- if ENV['HOPTOAD_API_KEY'].blank?
52
+ if ENV['HOPTOAD_API_KEY'] =~ /\S/
53
+ puts "... Done."
54
+ puts "Heroku's Airbrake API Key is '#{ENV['HOPTOAD_API_KEY']}'"
55
+ else
53
56
  puts "... Failed."
54
57
  puts "WARNING: We were unable to detect the Airbrake API Key from your Heroku environment."
55
58
  puts "Your Heroku application environment may not be configured correctly."
56
59
  exit 1
57
- else
58
- puts "... Done."
59
- puts "Heroku's Airbrake API Key is '#{ENV['HOPTOAD_API_KEY']}'"
60
60
  end
61
61
  end
62
62
 
@@ -66,7 +66,7 @@ class AirbrakeGenerator < Rails::Generator::Base
66
66
  end
67
67
 
68
68
  def heroku_api_key
69
- heroku_var("(hoptoad|airbrake)_api_key",options[:app]).split.find {|x| x unless x.blank?}
69
+ heroku_var("(hoptoad|airbrake)_api_key",options[:app]).split.find {|x| x =~ /\S/ }
70
70
  end
71
71
 
72
72
  def heroku?
@@ -8,14 +8,6 @@ require 'net/https'
8
8
  require 'rubygems'
9
9
  require 'logger'
10
10
 
11
- begin
12
- require 'active_support/core_ext/object/blank'
13
- rescue
14
- require 'activesupport'
15
- require 'activesupport/core_ext'
16
- end
17
-
18
-
19
11
  require 'airbrake/version'
20
12
  require 'airbrake/configuration'
21
13
  require 'airbrake/notice'
@@ -66,6 +58,7 @@ module Airbrake
66
58
  info = "[Ruby: #{RUBY_VERSION}]"
67
59
  info << " [#{configuration.framework}]" if configuration.framework
68
60
  info << " [Env: #{configuration.environment_name}]" if configuration.environment_name
61
+ info
69
62
  end
70
63
 
71
64
  # Writes out the given message to the #logger
@@ -76,7 +69,7 @@ module Airbrake
76
69
  # Look for the Rails logger currently defined
77
70
  def logger
78
71
  self.configuration.logger ||
79
- Logger.new(RUBY_PLATFORM =~ /(mingw|bccwin|wince|mswin32)/i ? 'NUL:' : '/dev/null')
72
+ Logger.new(nil)
80
73
  end
81
74
 
82
75
  # Call this method to modify defaults in your initializers.