honeybadger 1.8.1 → 1.9.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +61 -19
- data/Guardfile +4 -4
- data/MIT-LICENSE +1 -0
- data/README.md +2 -2
- data/Rakefile +4 -14
- data/features/rails.feature +1 -1
- data/gemfiles/rack.gemfile.lock +62 -27
- data/gemfiles/rails2.3.gemfile.lock +73 -36
- data/gemfiles/rails3.0.gemfile.lock +59 -26
- data/gemfiles/rails3.1.gemfile.lock +59 -26
- data/gemfiles/rails3.2.gemfile.lock +63 -30
- data/gemfiles/rails4.gemfile.lock +69 -36
- data/gemfiles/rake.gemfile.lock +62 -27
- data/gemfiles/sinatra.gemfile.lock +62 -27
- data/honeybadger.gemspec +31 -17
- data/lib/honeybadger.rb +2 -3
- data/lib/honeybadger/array.rb +53 -0
- data/lib/honeybadger/configuration.rb +19 -2
- data/lib/honeybadger/monitor.rb +16 -0
- data/lib/honeybadger/monitor/railtie.rb +52 -0
- data/lib/honeybadger/monitor/sender.rb +33 -0
- data/lib/honeybadger/monitor/worker.rb +71 -0
- data/lib/honeybadger/railtie.rb +10 -0
- data/lib/honeybadger/sender.rb +60 -41
- data/{test/unit/backtrace_test.rb → spec/honeybadger/backtrace_spec.rb} +69 -71
- data/{test/unit/capistrano_test.rb → spec/honeybadger/capistrano_spec.rb} +8 -9
- data/{test/unit/configuration_test.rb → spec/honeybadger/configuration_spec.rb} +85 -59
- data/spec/honeybadger/logger_spec.rb +65 -0
- data/spec/honeybadger/monitor/worker_spec.rb +189 -0
- data/{test/unit/notice_test.rb → spec/honeybadger/notice_spec.rb} +169 -185
- data/spec/honeybadger/notifier_spec.rb +252 -0
- data/spec/honeybadger/rack_spec.rb +84 -0
- data/{test/unit/rails/action_controller_catcher_test.rb → spec/honeybadger/rails/action_controller_spec.rb} +65 -57
- data/{test/unit/rails_test.rb → spec/honeybadger/rails_spec.rb} +8 -8
- data/spec/honeybadger/sender_spec.rb +249 -0
- data/spec/honeybadger_tasks_spec.rb +165 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/array_including.rb +31 -0
- data/spec/support/backtraced_exception.rb +9 -0
- data/spec/support/collected_sender.rb +12 -0
- data/spec/support/defines_constants.rb +18 -0
- data/{test/test_helper.rb → spec/support/helpers.rb} +8 -61
- metadata +93 -45
- data/test/unit/honeybadger_tasks_test.rb +0 -167
- data/test/unit/logger_test.rb +0 -74
- data/test/unit/notifier_test.rb +0 -265
- data/test/unit/rack_test.rb +0 -88
- data/test/unit/sender_test.rb +0 -290
@@ -0,0 +1,252 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Honeybadger' do
|
4
|
+
class OriginalException < Exception
|
5
|
+
end
|
6
|
+
|
7
|
+
class ContinuedException < Exception
|
8
|
+
end
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
reset_config
|
12
|
+
end
|
13
|
+
|
14
|
+
def assert_sends(notice, notice_args)
|
15
|
+
Honeybadger::Notice.should_receive(:new).with(hash_including(notice_args))
|
16
|
+
Honeybadger.sender.should_receive(:send_to_honeybadger).with(notice)
|
17
|
+
end
|
18
|
+
|
19
|
+
def set_public_env
|
20
|
+
Honeybadger.configure { |config| config.environment_name = 'production' }
|
21
|
+
end
|
22
|
+
|
23
|
+
def set_development_env
|
24
|
+
Honeybadger.configure { |config| config.environment_name = 'development' }
|
25
|
+
end
|
26
|
+
|
27
|
+
it "yields and save a configuration when configuring" do
|
28
|
+
yielded_configuration = nil
|
29
|
+
Honeybadger.configure do |config|
|
30
|
+
yielded_configuration = config
|
31
|
+
end
|
32
|
+
|
33
|
+
expect(yielded_configuration).to be_a Honeybadger::Configuration
|
34
|
+
expect(yielded_configuration).to be Honeybadger.configuration
|
35
|
+
end
|
36
|
+
|
37
|
+
it "does not remove existing config options when configuring twice" do
|
38
|
+
first_config = nil
|
39
|
+
Honeybadger.configure do |config|
|
40
|
+
first_config = config
|
41
|
+
end
|
42
|
+
Honeybadger.configure do |config|
|
43
|
+
expect(config).to be first_config
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it "configures the sender" do
|
48
|
+
sender = stub_sender
|
49
|
+
Honeybadger::Sender.stub(:new => sender)
|
50
|
+
|
51
|
+
Honeybadger.configure { |yielded_config| Honeybadger::Sender.should_receive(:new).with(yielded_config) }
|
52
|
+
expect(Honeybadger.sender).to be sender
|
53
|
+
end
|
54
|
+
|
55
|
+
it "creates and send a notice asynchronously" do
|
56
|
+
set_public_env
|
57
|
+
notice = stub_notice!
|
58
|
+
notice_args = { :error_message => 'uh oh' }
|
59
|
+
|
60
|
+
async_expectation = double(:received => true)
|
61
|
+
async_handler = Proc.new do |n|
|
62
|
+
async_expectation.received
|
63
|
+
n.deliver
|
64
|
+
end
|
65
|
+
|
66
|
+
Honeybadger.configure do |config|
|
67
|
+
config.async = async_handler
|
68
|
+
end
|
69
|
+
|
70
|
+
stub_sender!
|
71
|
+
|
72
|
+
async_expectation.should_receive(:received)
|
73
|
+
assert_sends(notice, notice_args)
|
74
|
+
|
75
|
+
Honeybadger.notify(notice_args)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "creates and send a notice for an exception" do
|
79
|
+
set_public_env
|
80
|
+
exception = build_exception
|
81
|
+
stub_sender!
|
82
|
+
notice = stub_notice!
|
83
|
+
|
84
|
+
assert_sends notice, :exception => exception
|
85
|
+
Honeybadger.notify(exception)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "creates and send a notice for a hash" do
|
89
|
+
set_public_env
|
90
|
+
notice = stub_notice!
|
91
|
+
notice_args = { :error_message => 'uh oh' }
|
92
|
+
stub_sender!
|
93
|
+
|
94
|
+
assert_sends(notice, notice_args)
|
95
|
+
Honeybadger.notify(notice_args)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "does not pass the hash as an exception when sending a notice for it" do
|
99
|
+
set_public_env
|
100
|
+
stub_notice!
|
101
|
+
notice_args = { :error_message => 'uh oh' }
|
102
|
+
stub_sender!
|
103
|
+
|
104
|
+
Honeybadger::Notice.should_receive(:new).with(hash_excluding(:exception))
|
105
|
+
Honeybadger.notify(notice_args)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "creates and send a notice for an exception that responds to to_hash" do
|
109
|
+
set_public_env
|
110
|
+
exception = build_exception
|
111
|
+
notice = stub_notice!
|
112
|
+
notice_args = { :error_message => 'uh oh' }
|
113
|
+
exception.stub(:to_hash).and_return(notice_args)
|
114
|
+
stub_sender!
|
115
|
+
|
116
|
+
assert_sends(notice, notice_args.merge(:exception => exception))
|
117
|
+
Honeybadger.notify(exception)
|
118
|
+
end
|
119
|
+
|
120
|
+
it "creates and sent a notice for an exception and hash" do
|
121
|
+
set_public_env
|
122
|
+
exception = build_exception
|
123
|
+
notice = stub_notice!
|
124
|
+
notice_args = { :error_message => 'uh oh' }
|
125
|
+
stub_sender!
|
126
|
+
|
127
|
+
assert_sends(notice, notice_args.merge(:exception => exception))
|
128
|
+
Honeybadger.notify(exception, notice_args)
|
129
|
+
end
|
130
|
+
|
131
|
+
it "does not create a notice in a development environment" do
|
132
|
+
set_development_env
|
133
|
+
sender = stub_sender!
|
134
|
+
|
135
|
+
sender.should_receive(:send_to_honeybadger).never
|
136
|
+
|
137
|
+
Honeybadger.notify(build_exception)
|
138
|
+
Honeybadger.notify_or_ignore(build_exception)
|
139
|
+
end
|
140
|
+
|
141
|
+
it "does not deliver an ignored exception when notifying implicitly" do
|
142
|
+
set_public_env
|
143
|
+
exception = build_exception
|
144
|
+
sender = stub_sender!
|
145
|
+
notice = stub_notice!
|
146
|
+
notice.stub(:ignore? => true)
|
147
|
+
|
148
|
+
sender.should_receive(:send_to_honeybadger).never
|
149
|
+
|
150
|
+
Honeybadger.notify_or_ignore(exception)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "delivers an ignored exception when notifying manually" do
|
154
|
+
set_public_env
|
155
|
+
exception = build_exception
|
156
|
+
stub_sender!
|
157
|
+
notice = stub_notice!
|
158
|
+
notice.stub(:ignore? => true)
|
159
|
+
|
160
|
+
assert_sends(notice, :exception => exception)
|
161
|
+
Honeybadger.notify(exception)
|
162
|
+
end
|
163
|
+
|
164
|
+
it "passes config to created notices" do
|
165
|
+
exception = build_exception
|
166
|
+
config_opts = { 'one' => 'two', 'three' => 'four' }
|
167
|
+
stub_notice!
|
168
|
+
stub_sender!
|
169
|
+
Honeybadger.configuration = double('config', :merge => config_opts, :public? => true, :async? => false)
|
170
|
+
|
171
|
+
Honeybadger::Notice.should_receive(:new).with(hash_including(config_opts))
|
172
|
+
Honeybadger.notify(exception)
|
173
|
+
end
|
174
|
+
|
175
|
+
context "building notice JSON for an exception" do
|
176
|
+
before(:each) do
|
177
|
+
@params = { :controller => "users", :action => "create" }
|
178
|
+
@exception = build_exception
|
179
|
+
@hash = Honeybadger.build_lookup_hash_for(@exception, @params)
|
180
|
+
end
|
181
|
+
|
182
|
+
it "sets action" do
|
183
|
+
expect(@hash[:action]).to eq @params[:action]
|
184
|
+
end
|
185
|
+
|
186
|
+
it "sets controller" do
|
187
|
+
expect(@hash[:component]).to eq @params[:controller]
|
188
|
+
end
|
189
|
+
|
190
|
+
it "sets line number" do
|
191
|
+
expect(@hash[:line_number]).to match /\d+/
|
192
|
+
end
|
193
|
+
|
194
|
+
it "sets file" do
|
195
|
+
expect(@hash[:file]).to match /honeybadger\/rack_test\.rb$/
|
196
|
+
end
|
197
|
+
|
198
|
+
it "sets environment_name to production" do
|
199
|
+
expect(@hash[:environment_name]).to eq 'production'
|
200
|
+
end
|
201
|
+
|
202
|
+
it "sets error class" do
|
203
|
+
expect(@hash[:error_class]).to eq @exception.class.to_s
|
204
|
+
end
|
205
|
+
|
206
|
+
it "does not set file or line number with no backtrace" do
|
207
|
+
@exception.stub(:backtrace).and_return([])
|
208
|
+
|
209
|
+
@hash = Honeybadger.build_lookup_hash_for(@exception)
|
210
|
+
|
211
|
+
@hash[:line_number].should be_nil
|
212
|
+
@hash[:file].should be_nil
|
213
|
+
end
|
214
|
+
|
215
|
+
it "does not set action or controller when not provided" do
|
216
|
+
@hash = Honeybadger.build_lookup_hash_for(@exception)
|
217
|
+
|
218
|
+
@hash[:action].should be_nil
|
219
|
+
@hash[:controller].should be_nil
|
220
|
+
end
|
221
|
+
|
222
|
+
context "when an exception that provides #original_exception is raised" do
|
223
|
+
before(:each) do
|
224
|
+
@exception.stub(:original_exception).and_return(begin
|
225
|
+
raise OriginalException.new
|
226
|
+
rescue Exception => e
|
227
|
+
e
|
228
|
+
end)
|
229
|
+
end
|
230
|
+
|
231
|
+
it "unwraps exceptions that provide #original_exception" do
|
232
|
+
@hash = Honeybadger.build_lookup_hash_for(@exception)
|
233
|
+
expect(@hash[:error_class]).to eq "OriginalException"
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
context "when an exception that provides #continued_exception is raised" do
|
238
|
+
before(:each) do
|
239
|
+
@exception.stub(:continued_exception).and_return(begin
|
240
|
+
raise ContinuedException.new
|
241
|
+
rescue Exception => e
|
242
|
+
e
|
243
|
+
end)
|
244
|
+
end
|
245
|
+
|
246
|
+
it "unwraps exceptions that provide #continued_exception" do
|
247
|
+
@hash = Honeybadger.build_lookup_hash_for(@exception)
|
248
|
+
expect(@hash[:error_class]).to eq "ContinuedException"
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Honeybadger::Rack do
|
4
|
+
it "calls the upstream app with the environment" do
|
5
|
+
environment = { 'key' => 'value' }
|
6
|
+
app = lambda { |env| ['response', {}, env] }
|
7
|
+
stack = Honeybadger::Rack.new(app)
|
8
|
+
|
9
|
+
response = stack.call(environment)
|
10
|
+
|
11
|
+
expect(response).to eq ['response', {}, environment]
|
12
|
+
end
|
13
|
+
|
14
|
+
it "delivers an exception raised while calling an upstream app" do
|
15
|
+
Honeybadger.stub(:notify_or_ignore)
|
16
|
+
|
17
|
+
exception = build_exception
|
18
|
+
environment = { 'key' => 'value' }
|
19
|
+
app = lambda do |env|
|
20
|
+
raise exception
|
21
|
+
end
|
22
|
+
|
23
|
+
Honeybadger.should_receive(:notify_or_ignore).with(exception, :rack_env => environment)
|
24
|
+
|
25
|
+
begin
|
26
|
+
stack = Honeybadger::Rack.new(app)
|
27
|
+
stack.call(environment)
|
28
|
+
rescue Exception => raised
|
29
|
+
expect(raised).to eq exception
|
30
|
+
else
|
31
|
+
fail "Didn't raise an exception"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "delivers an exception in rack.exception" do
|
36
|
+
Honeybadger.stub(:notify_or_ignore)
|
37
|
+
exception = build_exception
|
38
|
+
environment = { 'key' => 'value' }
|
39
|
+
|
40
|
+
response = [200, {}, ['okay']]
|
41
|
+
app = lambda do |env|
|
42
|
+
env['rack.exception'] = exception
|
43
|
+
response
|
44
|
+
end
|
45
|
+
stack = Honeybadger::Rack.new(app)
|
46
|
+
|
47
|
+
Honeybadger.should_receive(:notify_or_ignore).with(exception, :rack_env => environment)
|
48
|
+
|
49
|
+
actual_response = stack.call(environment)
|
50
|
+
|
51
|
+
expect(actual_response).to eq response
|
52
|
+
end
|
53
|
+
|
54
|
+
it "delivers an exception in sinatra.error" do
|
55
|
+
Honeybadger.stub(:notify_or_ignore)
|
56
|
+
exception = build_exception
|
57
|
+
environment = { 'key' => 'value' }
|
58
|
+
|
59
|
+
response = [200, {}, ['okay']]
|
60
|
+
app = lambda do |env|
|
61
|
+
env['sinatra.error'] = exception
|
62
|
+
response
|
63
|
+
end
|
64
|
+
stack = Honeybadger::Rack.new(app)
|
65
|
+
|
66
|
+
Honeybadger.should_receive(:notify_or_ignore).with(exception, :rack_env => environment)
|
67
|
+
|
68
|
+
actual_response = stack.call(environment)
|
69
|
+
|
70
|
+
expect(actual_response).to eq response
|
71
|
+
end
|
72
|
+
|
73
|
+
it "clears context after app is called" do
|
74
|
+
Honeybadger.context( :foo => :bar )
|
75
|
+
expect(Thread.current[:honeybadger_context]).to eq({ :foo => :bar })
|
76
|
+
|
77
|
+
app = lambda { |env| ['response', {}, env] }
|
78
|
+
stack = Honeybadger::Rack.new(app)
|
79
|
+
|
80
|
+
stack.call({})
|
81
|
+
|
82
|
+
expect(Thread.current[:honeybadger_context]).to be_nil
|
83
|
+
end
|
84
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
begin
|
4
4
|
require 'active_support'
|
@@ -6,11 +6,10 @@ begin
|
|
6
6
|
require 'action_controller/test_process'
|
7
7
|
require 'honeybadger/rails'
|
8
8
|
|
9
|
-
|
9
|
+
describe Honeybadger::Rails::ActionControllerCatcher do
|
10
10
|
include DefinesConstants
|
11
11
|
|
12
|
-
|
13
|
-
super
|
12
|
+
before(:each) do
|
14
13
|
reset_config
|
15
14
|
Honeybadger.sender = CollectingSender.new
|
16
15
|
define_constant('RAILS_ROOT', '/path/to/rails/root')
|
@@ -45,7 +44,7 @@ begin
|
|
45
44
|
end
|
46
45
|
|
47
46
|
def assert_sent_element(value, &block)
|
48
|
-
|
47
|
+
expect(yield(last_sent_notice_payload)).to eq stringify_array_elements(value)
|
49
48
|
end
|
50
49
|
|
51
50
|
def stringify_array_elements(data)
|
@@ -87,13 +86,11 @@ begin
|
|
87
86
|
end
|
88
87
|
|
89
88
|
def last_sent_notice_payload
|
90
|
-
|
89
|
+
expect(last_sent_notice_json).to_not be_nil
|
91
90
|
JSON.parse(last_sent_notice_json)
|
92
91
|
end
|
93
92
|
|
94
|
-
def
|
95
|
-
opts[:request] ||= ActionController::TestRequest.new
|
96
|
-
opts[:response] ||= ActionController::TestResponse.new
|
93
|
+
def build_controller(opts = {}, &action)
|
97
94
|
klass = build_controller_class do
|
98
95
|
cattr_accessor :local
|
99
96
|
define_method(:index, &action)
|
@@ -101,9 +98,24 @@ begin
|
|
101
98
|
local
|
102
99
|
end
|
103
100
|
end
|
101
|
+
|
104
102
|
if opts[:filters]
|
105
|
-
klass.filter_parameter_logging
|
103
|
+
klass.filter_parameter_logging(*opts[:filters])
|
106
104
|
end
|
105
|
+
|
106
|
+
klass.consider_all_requests_local = opts[:all_local]
|
107
|
+
klass.local = opts[:local]
|
108
|
+
controller = klass.new
|
109
|
+
controller.stub(:rescue_action_in_public_without_honeybadger)
|
110
|
+
controller
|
111
|
+
end
|
112
|
+
|
113
|
+
def process_action(opts = {}, &action)
|
114
|
+
opts[:request] ||= ActionController::TestRequest.new
|
115
|
+
opts[:response] ||= ActionController::TestResponse.new
|
116
|
+
|
117
|
+
controller = opts[:controller] || build_controller(opts, &action)
|
118
|
+
|
107
119
|
if opts[:user_agent]
|
108
120
|
if opts[:request].respond_to?(:user_agent=)
|
109
121
|
opts[:request].user_agent = opts[:user_agent]
|
@@ -111,17 +123,16 @@ begin
|
|
111
123
|
opts[:request].env["HTTP_USER_AGENT"] = opts[:user_agent]
|
112
124
|
end
|
113
125
|
end
|
126
|
+
|
114
127
|
if opts[:port]
|
115
128
|
opts[:request].port = opts[:port]
|
116
129
|
end
|
117
|
-
|
118
|
-
klass.local = opts[:local]
|
119
|
-
controller = klass.new
|
120
|
-
controller.stubs(:rescue_action_in_public_without_honeybadger)
|
130
|
+
|
121
131
|
opts[:request].query_parameters = opts[:request].query_parameters.merge(opts[:params] || {})
|
122
132
|
opts[:request].session = ActionController::TestSession.new(opts[:session] || {})
|
123
133
|
# Prevents request.fullpath from crashing Rails in tests
|
124
134
|
opts[:request].env['REQUEST_URI'] = opts[:request].request_uri
|
135
|
+
|
125
136
|
controller.process(opts[:request], opts[:response])
|
126
137
|
controller
|
127
138
|
end
|
@@ -138,120 +149,120 @@ begin
|
|
138
149
|
process_action(args) { raise "Hello" }
|
139
150
|
end
|
140
151
|
|
141
|
-
|
152
|
+
it "delivers notices from exceptions raised in public requests" do
|
142
153
|
process_action_with_automatic_notification
|
143
154
|
assert_caught_and_sent
|
144
155
|
end
|
145
156
|
|
146
|
-
|
157
|
+
it "not deliver notices from exceptions in local requests" do
|
147
158
|
process_action_with_automatic_notification(:local => true)
|
148
159
|
assert_caught_and_not_sent
|
149
160
|
end
|
150
161
|
|
151
|
-
|
162
|
+
it "not deliver notices from exceptions when all requests are local" do
|
152
163
|
process_action_with_automatic_notification(:all_local => true)
|
153
164
|
assert_caught_and_not_sent
|
154
165
|
end
|
155
166
|
|
156
|
-
|
167
|
+
it "not deliver notices from actions that don't raise" do
|
157
168
|
controller = process_action { render :text => 'Hello' }
|
158
169
|
assert_caught_and_not_sent
|
159
|
-
|
170
|
+
expect(controller.response.body).to eq 'Hello'
|
160
171
|
end
|
161
172
|
|
162
|
-
|
173
|
+
it "not deliver ignored exceptions raised by actions" do
|
163
174
|
ignore(RuntimeError)
|
164
175
|
process_action_with_automatic_notification
|
165
176
|
assert_caught_and_not_sent
|
166
177
|
end
|
167
178
|
|
168
|
-
|
179
|
+
it "deliver ignored exception raised manually" do
|
169
180
|
ignore(RuntimeError)
|
170
181
|
process_action_with_manual_notification
|
171
182
|
assert_caught_and_sent
|
172
183
|
end
|
173
184
|
|
174
|
-
|
185
|
+
it "deliver manually sent notices in public requests" do
|
175
186
|
process_action_with_manual_notification
|
176
187
|
assert_caught_and_sent
|
177
188
|
end
|
178
189
|
|
179
|
-
|
190
|
+
it "not deliver manually sent notices in local requests" do
|
180
191
|
process_action_with_manual_notification(:local => true)
|
181
192
|
assert_caught_and_not_sent
|
182
193
|
end
|
183
194
|
|
184
|
-
|
195
|
+
it "not deliver manually sent notices when all requests are local" do
|
185
196
|
process_action_with_manual_notification(:all_local => true)
|
186
197
|
assert_caught_and_not_sent
|
187
198
|
end
|
188
199
|
|
189
|
-
|
190
|
-
controller =
|
191
|
-
|
192
|
-
|
200
|
+
it "continue with default behavior after delivering an exception" do
|
201
|
+
controller = build_controller(:public => true) { raise 'cobras!' }
|
202
|
+
controller.should_receive(:rescue_action_in_public_without_honeybadger)
|
203
|
+
process_action(:controller => controller)
|
193
204
|
end
|
194
205
|
|
195
|
-
|
196
|
-
|
197
|
-
|
206
|
+
it "not create actions from Honeybadger methods" do
|
207
|
+
build_controller_class.new
|
208
|
+
expect(Honeybadger::Rails::ActionControllerCatcher.instance_methods).to be_empty
|
198
209
|
end
|
199
210
|
|
200
|
-
|
211
|
+
it "ignore exceptions when user agent is being ignored by regular expression" do
|
201
212
|
Honeybadger.configuration.ignore_user_agent_only = [/Ignored/]
|
202
213
|
process_action_with_automatic_notification(:user_agent => 'ShouldBeIgnored')
|
203
214
|
assert_caught_and_not_sent
|
204
215
|
end
|
205
216
|
|
206
|
-
|
217
|
+
it "ignore exceptions when user agent is being ignored by string" do
|
207
218
|
Honeybadger.configuration.ignore_user_agent_only = ['IgnoredUserAgent']
|
208
219
|
process_action_with_automatic_notification(:user_agent => 'IgnoredUserAgent')
|
209
220
|
assert_caught_and_not_sent
|
210
221
|
end
|
211
222
|
|
212
|
-
|
223
|
+
it "not ignore exceptions when user agent is not being ignored" do
|
213
224
|
Honeybadger.configuration.ignore_user_agent_only = ['IgnoredUserAgent']
|
214
225
|
process_action_with_automatic_notification(:user_agent => 'NonIgnoredAgent')
|
215
226
|
assert_caught_and_sent
|
216
227
|
end
|
217
228
|
|
218
|
-
|
229
|
+
it "send session data for manual notifications" do
|
219
230
|
data = { 'one' => 'two' }
|
220
231
|
process_action_with_manual_notification(:session => data)
|
221
232
|
assert_sent_hash(data) { |h| h['request']['session'] }
|
222
233
|
end
|
223
234
|
|
224
|
-
|
235
|
+
it "send session data for automatic notification" do
|
225
236
|
data = { 'one' => 'two' }
|
226
237
|
process_action_with_automatic_notification(:session => data)
|
227
238
|
assert_sent_hash(data) { |h| h['request']['session'] }
|
228
239
|
end
|
229
240
|
|
230
|
-
|
241
|
+
it "send request data for manual notification" do
|
231
242
|
params = { 'controller' => "honeybadger_test", 'action' => "index" }
|
232
243
|
controller = process_action_with_manual_notification(:params => params)
|
233
244
|
assert_sent_request_info_for controller.request
|
234
245
|
end
|
235
246
|
|
236
|
-
|
247
|
+
it "send request data for manual notification with non-standard port" do
|
237
248
|
params = { 'controller' => "honeybadger_test", 'action' => "index" }
|
238
249
|
controller = process_action_with_manual_notification(:params => params, :port => 81)
|
239
250
|
assert_sent_request_info_for controller.request
|
240
251
|
end
|
241
252
|
|
242
|
-
|
253
|
+
it "send request data for automatic notification" do
|
243
254
|
params = { 'controller' => "honeybadger_test", 'action' => "index" }
|
244
255
|
controller = process_action_with_automatic_notification(:params => params)
|
245
256
|
assert_sent_request_info_for controller.request
|
246
257
|
end
|
247
258
|
|
248
|
-
|
259
|
+
it "send request data for automatic notification with non-standard port" do
|
249
260
|
params = { 'controller' => "honeybadger_test", 'action' => "index" }
|
250
261
|
controller = process_action_with_automatic_notification(:params => params, :port => 81)
|
251
262
|
assert_sent_request_info_for controller.request
|
252
263
|
end
|
253
264
|
|
254
|
-
|
265
|
+
it "use standard rails logging filters on params and session and env" do
|
255
266
|
filtered_params = { "abc" => "123",
|
256
267
|
"def" => "456",
|
257
268
|
"ghi" => "[FILTERED]" }
|
@@ -272,38 +283,35 @@ begin
|
|
272
283
|
assert_sent_hash(filtered_session) { |h| h['request']['session'] }
|
273
284
|
end
|
274
285
|
|
275
|
-
|
286
|
+
it "call session.to_hash if available" do
|
276
287
|
hash_data = {:key => :value}
|
277
288
|
|
278
289
|
session = ActionController::TestSession.new
|
279
|
-
ActionController::TestSession.
|
280
|
-
session.
|
290
|
+
ActionController::TestSession.stub(:new).and_return(session)
|
291
|
+
session.stub(:to_hash).and_return(hash_data)
|
292
|
+
|
293
|
+
session.should_receive(:to_hash)
|
294
|
+
session.should_receive(:data).never
|
281
295
|
|
282
296
|
process_action_with_automatic_notification
|
283
|
-
assert_received(session, :to_hash)
|
284
|
-
assert_received(session, :data) { |expect| expect.never }
|
285
297
|
assert_caught_and_sent
|
286
298
|
end
|
287
299
|
|
288
|
-
|
300
|
+
it "call session.data if session.to_hash is undefined" do
|
289
301
|
hash_data = {:key => :value}
|
290
302
|
|
291
303
|
session = ActionController::TestSession.new
|
292
|
-
ActionController::TestSession.
|
293
|
-
session.
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
end
|
304
|
+
ActionController::TestSession.stub(:new).and_return(session)
|
305
|
+
session.stub(:data).and_return(hash_data)
|
306
|
+
session.stub(:respond_to?).with(:to_hash).and_return(false)
|
307
|
+
|
308
|
+
session.should_receive(:to_hash).never
|
309
|
+
session.should_receive(:data).at_least(1).times
|
299
310
|
|
300
311
|
process_action_with_automatic_notification
|
301
|
-
assert_received(session, :to_hash) { |expect| expect.never }
|
302
|
-
assert_received(session, :data) { |expect| expect.at_least_once }
|
303
312
|
assert_caught_and_sent
|
304
313
|
end
|
305
314
|
end
|
306
|
-
|
307
315
|
rescue LoadError
|
308
316
|
nil
|
309
317
|
end
|