honeybadger 1.16.7 → 2.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +19 -0
- data/README.md +37 -16
- data/bin/honeybadger +5 -0
- data/lib/honeybadger.rb +167 -191
- data/lib/honeybadger/agent.rb +136 -0
- data/lib/honeybadger/backend.rb +26 -0
- data/lib/honeybadger/backend/base.rb +66 -0
- data/lib/honeybadger/backend/debug.rb +12 -0
- data/lib/honeybadger/backend/null.rb +16 -0
- data/lib/honeybadger/backend/server.rb +51 -0
- data/lib/honeybadger/backend/test.rb +24 -0
- data/lib/honeybadger/backtrace.rb +29 -24
- data/lib/honeybadger/cli.rb +367 -0
- data/lib/honeybadger/config.rb +333 -0
- data/lib/honeybadger/config/callbacks.rb +70 -0
- data/lib/honeybadger/config/defaults.rb +175 -0
- data/lib/honeybadger/config/env.rb +40 -0
- data/lib/honeybadger/config/yaml.rb +43 -0
- data/lib/honeybadger/const.rb +28 -0
- data/lib/honeybadger/init/rails.rb +84 -0
- data/lib/honeybadger/init/sinatra.rb +27 -0
- data/lib/honeybadger/logging.rb +133 -0
- data/lib/honeybadger/notice.rb +243 -280
- data/lib/honeybadger/plugin.rb +110 -0
- data/lib/honeybadger/plugins/delayed_job.rb +22 -0
- data/lib/honeybadger/{integrations → plugins}/delayed_job/plugin.rb +6 -7
- data/lib/honeybadger/{integrations → plugins}/local_variables.rb +7 -8
- data/lib/honeybadger/{integrations → plugins}/net_http.rb +10 -8
- data/lib/honeybadger/plugins/passenger.rb +24 -0
- data/lib/honeybadger/plugins/rails.rb +61 -0
- data/lib/honeybadger/plugins/sidekiq.rb +35 -0
- data/lib/honeybadger/{integrations → plugins}/thor.rb +9 -8
- data/lib/honeybadger/{integrations → plugins}/unicorn.rb +10 -9
- data/lib/honeybadger/rack/error_notifier.rb +44 -27
- data/lib/honeybadger/rack/metrics_reporter.rb +41 -0
- data/lib/honeybadger/rack/request_hash.rb +50 -0
- data/lib/honeybadger/rack/user_feedback.rb +15 -10
- data/lib/honeybadger/rack/user_informer.rb +14 -3
- data/lib/honeybadger/trace.rb +185 -0
- data/lib/honeybadger/util/http.rb +79 -0
- data/lib/honeybadger/util/request_sanitizer.rb +35 -0
- data/lib/honeybadger/util/sanitizer.rb +71 -0
- data/lib/honeybadger/util/stats.rb +31 -0
- data/lib/honeybadger/version.rb +4 -0
- data/lib/honeybadger/worker.rb +224 -0
- data/lib/honeybadger/worker/batch.rb +50 -0
- data/lib/honeybadger/worker/metered_queue.rb +80 -0
- data/lib/honeybadger/worker/metrics_collection.rb +61 -0
- data/lib/honeybadger/worker/metrics_collector.rb +96 -0
- data/{lib/honeybadger/capistrano.rb → vendor/capistrano-honeybadger/lib/capistrano/honeybadger.rb} +1 -3
- data/vendor/capistrano-honeybadger/lib/capistrano/tasks/deploy.cap +76 -0
- data/vendor/capistrano-honeybadger/lib/honeybadger/capistrano.rb +2 -0
- data/{lib → vendor/capistrano-honeybadger/lib}/honeybadger/capistrano/legacy.rb +16 -15
- data/vendor/thor/lib/thor.rb +484 -0
- data/vendor/thor/lib/thor/actions.rb +319 -0
- data/vendor/thor/lib/thor/actions/create_file.rb +103 -0
- data/vendor/thor/lib/thor/actions/create_link.rb +59 -0
- data/vendor/thor/lib/thor/actions/directory.rb +118 -0
- data/vendor/thor/lib/thor/actions/empty_directory.rb +135 -0
- data/vendor/thor/lib/thor/actions/file_manipulation.rb +316 -0
- data/vendor/thor/lib/thor/actions/inject_into_file.rb +107 -0
- data/vendor/thor/lib/thor/base.rb +656 -0
- data/vendor/thor/lib/thor/command.rb +133 -0
- data/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +77 -0
- data/vendor/thor/lib/thor/core_ext/io_binary_read.rb +10 -0
- data/vendor/thor/lib/thor/core_ext/ordered_hash.rb +98 -0
- data/vendor/thor/lib/thor/error.rb +32 -0
- data/vendor/thor/lib/thor/group.rb +281 -0
- data/vendor/thor/lib/thor/invocation.rb +178 -0
- data/vendor/thor/lib/thor/line_editor.rb +17 -0
- data/vendor/thor/lib/thor/line_editor/basic.rb +35 -0
- data/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
- data/vendor/thor/lib/thor/parser.rb +4 -0
- data/vendor/thor/lib/thor/parser/argument.rb +73 -0
- data/vendor/thor/lib/thor/parser/arguments.rb +175 -0
- data/vendor/thor/lib/thor/parser/option.rb +125 -0
- data/vendor/thor/lib/thor/parser/options.rb +218 -0
- data/vendor/thor/lib/thor/rake_compat.rb +71 -0
- data/vendor/thor/lib/thor/runner.rb +322 -0
- data/vendor/thor/lib/thor/shell.rb +81 -0
- data/vendor/thor/lib/thor/shell/basic.rb +421 -0
- data/vendor/thor/lib/thor/shell/color.rb +149 -0
- data/vendor/thor/lib/thor/shell/html.rb +126 -0
- data/vendor/thor/lib/thor/util.rb +267 -0
- data/vendor/thor/lib/thor/version.rb +3 -0
- metadata +97 -305
- data/Appraisals +0 -95
- data/CHANGELOG.md +0 -422
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -136
- data/Guardfile +0 -5
- data/MIT-LICENSE +0 -32
- data/Rakefile +0 -159
- data/features/metal.feature +0 -20
- data/features/rack.feature +0 -55
- data/features/rails.feature +0 -343
- data/features/rails3.x.feature +0 -26
- data/features/rake.feature +0 -25
- data/features/sinatra.feature +0 -27
- data/features/standalone.feature +0 -73
- data/features/step_definitions/metal_steps.rb +0 -24
- data/features/step_definitions/rack_steps.rb +0 -18
- data/features/step_definitions/rails_steps.rb +0 -270
- data/features/step_definitions/rake_steps.rb +0 -17
- data/features/step_definitions/standalone_steps.rb +0 -12
- data/features/step_definitions/thor_steps.rb +0 -4
- data/features/support/env.rb +0 -22
- data/features/support/honeybadger_failure_shim.rb.template +0 -5
- data/features/support/honeybadger_shim.rb.template +0 -6
- data/features/support/rails.rb +0 -202
- data/features/support/rake/Rakefile +0 -68
- data/features/support/test.thor +0 -22
- data/features/thor.feature +0 -5
- data/gemfiles/binding_of_caller.gemfile +0 -13
- data/gemfiles/delayed_job.gemfile +0 -13
- data/gemfiles/rack.gemfile +0 -13
- data/gemfiles/rails.gemfile +0 -16
- data/gemfiles/rails2.3.gemfile +0 -15
- data/gemfiles/rails3.0.gemfile +0 -16
- data/gemfiles/rails3.1.gemfile +0 -16
- data/gemfiles/rails3.2.gemfile +0 -16
- data/gemfiles/rails4.0.gemfile +0 -16
- data/gemfiles/rails4.1.gemfile +0 -16
- data/gemfiles/rake.gemfile +0 -13
- data/gemfiles/sinatra.gemfile +0 -13
- data/gemfiles/standalone.gemfile +0 -12
- data/gemfiles/thor.gemfile +0 -13
- data/generators/honeybadger/honeybadger_generator.rb +0 -95
- data/generators/honeybadger/lib/insert_commands.rb +0 -34
- data/generators/honeybadger/lib/rake_commands.rb +0 -24
- data/generators/honeybadger/templates/capistrano_hook.rb +0 -6
- data/generators/honeybadger/templates/honeybadger_tasks.rake +0 -25
- data/generators/honeybadger/templates/initializer.rb +0 -6
- data/honeybadger.gemspec +0 -174
- data/lib/honeybadger/array.rb +0 -53
- data/lib/honeybadger/capistrano/tasks.rake +0 -73
- data/lib/honeybadger/configuration.rb +0 -397
- data/lib/honeybadger/dependency.rb +0 -65
- data/lib/honeybadger/integrations.rb +0 -9
- data/lib/honeybadger/integrations/delayed_job.rb +0 -20
- data/lib/honeybadger/integrations/passenger.rb +0 -18
- data/lib/honeybadger/integrations/sidekiq.rb +0 -37
- data/lib/honeybadger/monitor.rb +0 -17
- data/lib/honeybadger/monitor/railtie.rb +0 -53
- data/lib/honeybadger/monitor/sender.rb +0 -44
- data/lib/honeybadger/monitor/trace.rb +0 -187
- data/lib/honeybadger/monitor/worker.rb +0 -169
- data/lib/honeybadger/payload.rb +0 -101
- data/lib/honeybadger/rack.rb +0 -12
- data/lib/honeybadger/rails.rb +0 -45
- data/lib/honeybadger/rails/action_controller_catcher.rb +0 -30
- data/lib/honeybadger/rails/controller_methods.rb +0 -78
- data/lib/honeybadger/rails/middleware/exceptions_catcher.rb +0 -29
- data/lib/honeybadger/rails3_tasks.rb +0 -94
- data/lib/honeybadger/railtie.rb +0 -52
- data/lib/honeybadger/rake_handler.rb +0 -66
- data/lib/honeybadger/sender.rb +0 -185
- data/lib/honeybadger/shared_tasks.rb +0 -56
- data/lib/honeybadger/stats.rb +0 -29
- data/lib/honeybadger/tasks.rb +0 -95
- data/lib/honeybadger/user_feedback.rb +0 -8
- data/lib/honeybadger/user_informer.rb +0 -8
- data/lib/honeybadger_tasks.rb +0 -69
- data/lib/rails/generators/honeybadger/honeybadger_generator.rb +0 -99
- data/rails/init.rb +0 -1
- data/resources/README.md +0 -34
- data/script/integration_test.rb +0 -38
- data/spec/allocation_stats.rb +0 -32
- data/spec/honeybadger/backtrace_spec.rb +0 -242
- data/spec/honeybadger/capistrano_spec.rb +0 -36
- data/spec/honeybadger/configuration_spec.rb +0 -328
- data/spec/honeybadger/dependency_spec.rb +0 -134
- data/spec/honeybadger/integrations/delayed_job_spec.rb +0 -82
- data/spec/honeybadger/integrations/local_variables_spec.rb +0 -60
- data/spec/honeybadger/integrations/net_http_spec.rb +0 -29
- data/spec/honeybadger/integrations/passenger_spec.rb +0 -29
- data/spec/honeybadger/integrations/sidekiq_spec.rb +0 -60
- data/spec/honeybadger/integrations/thor_spec.rb +0 -32
- data/spec/honeybadger/integrations/unicorn_spec.rb +0 -40
- data/spec/honeybadger/logger_spec.rb +0 -79
- data/spec/honeybadger/monitor/trace_spec.rb +0 -65
- data/spec/honeybadger/monitor/worker_spec.rb +0 -274
- data/spec/honeybadger/notice_spec.rb +0 -669
- data/spec/honeybadger/notifier_spec.rb +0 -328
- data/spec/honeybadger/payload_spec.rb +0 -162
- data/spec/honeybadger/rack_spec.rb +0 -85
- data/spec/honeybadger/rails/action_controller_spec.rb +0 -328
- data/spec/honeybadger/rails_spec.rb +0 -37
- data/spec/honeybadger/sender_spec.rb +0 -317
- data/spec/honeybadger/stats_spec.rb +0 -57
- data/spec/honeybadger/user_feedback_spec.rb +0 -80
- data/spec/honeybadger/user_informer_spec.rb +0 -30
- data/spec/honeybadger_tasks_spec.rb +0 -171
- data/spec/spec_helper.rb +0 -24
- data/spec/support/array_including.rb +0 -31
- data/spec/support/backtraced_exception.rb +0 -9
- data/spec/support/collected_sender.rb +0 -12
- data/spec/support/defines_constants.rb +0 -18
- data/spec/support/helpers.rb +0 -101
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rack'
|
3
|
-
|
4
|
-
describe Honeybadger::Rack::ErrorNotifier do
|
5
|
-
it "calls the upstream app with the environment" do
|
6
|
-
environment = { 'key' => 'value' }
|
7
|
-
app = lambda { |env| ['response', {}, env] }
|
8
|
-
stack = Honeybadger::Rack::ErrorNotifier.new(app)
|
9
|
-
|
10
|
-
response = stack.call(environment)
|
11
|
-
|
12
|
-
expect(response).to eq ['response', {}, environment]
|
13
|
-
end
|
14
|
-
|
15
|
-
it "delivers an exception raised while calling an upstream app" do
|
16
|
-
Honeybadger.stub(:notify_or_ignore)
|
17
|
-
|
18
|
-
exception = build_exception
|
19
|
-
environment = { 'key' => 'value' }
|
20
|
-
app = lambda do |env|
|
21
|
-
raise exception
|
22
|
-
end
|
23
|
-
|
24
|
-
Honeybadger.should_receive(:notify_or_ignore).with(exception, :rack_env => environment)
|
25
|
-
|
26
|
-
begin
|
27
|
-
stack = Honeybadger::Rack::ErrorNotifier.new(app)
|
28
|
-
stack.call(environment)
|
29
|
-
rescue Exception => raised
|
30
|
-
expect(raised).to eq exception
|
31
|
-
else
|
32
|
-
fail "Didn't raise an exception"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
it "delivers an exception in rack.exception" do
|
37
|
-
Honeybadger.stub(:notify_or_ignore)
|
38
|
-
exception = build_exception
|
39
|
-
environment = { 'key' => 'value' }
|
40
|
-
|
41
|
-
response = [200, {}, ['okay']]
|
42
|
-
app = lambda do |env|
|
43
|
-
env['rack.exception'] = exception
|
44
|
-
response
|
45
|
-
end
|
46
|
-
stack = Honeybadger::Rack::ErrorNotifier.new(app)
|
47
|
-
|
48
|
-
Honeybadger.should_receive(:notify_or_ignore).with(exception, :rack_env => environment)
|
49
|
-
|
50
|
-
actual_response = stack.call(environment)
|
51
|
-
|
52
|
-
expect(actual_response).to eq response
|
53
|
-
end
|
54
|
-
|
55
|
-
it "delivers an exception in sinatra.error" do
|
56
|
-
Honeybadger.stub(:notify_or_ignore)
|
57
|
-
exception = build_exception
|
58
|
-
environment = { 'key' => 'value' }
|
59
|
-
|
60
|
-
response = [200, {}, ['okay']]
|
61
|
-
app = lambda do |env|
|
62
|
-
env['sinatra.error'] = exception
|
63
|
-
response
|
64
|
-
end
|
65
|
-
stack = Honeybadger::Rack::ErrorNotifier.new(app)
|
66
|
-
|
67
|
-
Honeybadger.should_receive(:notify_or_ignore).with(exception, :rack_env => environment)
|
68
|
-
|
69
|
-
actual_response = stack.call(environment)
|
70
|
-
|
71
|
-
expect(actual_response).to eq response
|
72
|
-
end
|
73
|
-
|
74
|
-
it "clears context after app is called" do
|
75
|
-
Honeybadger.context( :foo => :bar )
|
76
|
-
expect(Thread.current[:honeybadger_context]).to eq({ :foo => :bar })
|
77
|
-
|
78
|
-
app = lambda { |env| ['response', {}, env] }
|
79
|
-
stack = Honeybadger::Rack::ErrorNotifier.new(app)
|
80
|
-
|
81
|
-
stack.call({})
|
82
|
-
|
83
|
-
expect(Thread.current[:honeybadger_context]).to be_nil
|
84
|
-
end
|
85
|
-
end
|
@@ -1,328 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'active_support'
|
5
|
-
require 'action_controller'
|
6
|
-
require 'action_controller/test_process'
|
7
|
-
require 'honeybadger/rails'
|
8
|
-
|
9
|
-
describe Honeybadger::Rails::ActionControllerCatcher do
|
10
|
-
include DefinesConstants
|
11
|
-
|
12
|
-
before(:each) do
|
13
|
-
reset_config
|
14
|
-
Honeybadger.sender = CollectingSender.new
|
15
|
-
define_constant('RAILS_ROOT', '/path/to/rails/root')
|
16
|
-
end
|
17
|
-
|
18
|
-
def ignore(exception_class)
|
19
|
-
Honeybadger.configuration.ignore << exception_class
|
20
|
-
end
|
21
|
-
|
22
|
-
def build_controller_class(&definition)
|
23
|
-
Class.new(ActionController::Base).tap do |klass|
|
24
|
-
klass.__send__(:include, Honeybadger::Rails::ActionControllerCatcher)
|
25
|
-
klass.class_eval(&definition) if definition
|
26
|
-
define_constant('HoneybadgerTestController', klass)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def assert_sent_hash(hash, &block)
|
31
|
-
hash.each do |key, value|
|
32
|
-
next if key.match(/^honeybadger\./) # We added this key.
|
33
|
-
|
34
|
-
new_block = Proc.new {
|
35
|
-
block.call(last_sent_notice_payload)[key]
|
36
|
-
}
|
37
|
-
|
38
|
-
if value.respond_to?(:to_hash)
|
39
|
-
assert_sent_hash(value.to_hash, &new_block)
|
40
|
-
else
|
41
|
-
assert_sent_element(value, &new_block)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def assert_sent_element(value, &block)
|
47
|
-
expect(yield(last_sent_notice_payload)).to eq stringify_array_elements(value)
|
48
|
-
end
|
49
|
-
|
50
|
-
def stringify_array_elements(data)
|
51
|
-
if data.is_a?(Array)
|
52
|
-
data.collect do |value|
|
53
|
-
stringify_array_elements(value)
|
54
|
-
end
|
55
|
-
elsif Honeybadger::Payload::OBJECT_WHITELIST.any? {|c| data.kind_of?(c) }
|
56
|
-
data
|
57
|
-
else
|
58
|
-
data.to_s
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def assert_sent_request_info_for(request)
|
63
|
-
params = request.parameters.to_hash
|
64
|
-
assert_sent_hash(params) { |h| h['request']['params'] }
|
65
|
-
assert_sent_element(params['controller']) { |h| h['request']['component'] }
|
66
|
-
assert_sent_element(params['action']) { |h| h['request']['action'] }
|
67
|
-
assert_sent_element(url_from_request(request)) { |h| h['request']['url'] }
|
68
|
-
assert_sent_hash(request.env.reject {|k,_| k == 'QUERY_STRING' || !k.match(/\A[A-Z_]+\Z/) }) { |h| h['request']['cgi_data'] }
|
69
|
-
end
|
70
|
-
|
71
|
-
def url_from_request(request)
|
72
|
-
url = "#{request.protocol}#{request.host}"
|
73
|
-
|
74
|
-
unless [80, 443].include?(request.port)
|
75
|
-
url << ":#{request.port}"
|
76
|
-
end
|
77
|
-
|
78
|
-
url << request.request_uri
|
79
|
-
url
|
80
|
-
end
|
81
|
-
|
82
|
-
def sender
|
83
|
-
Honeybadger.sender
|
84
|
-
end
|
85
|
-
|
86
|
-
def last_sent_notice_json
|
87
|
-
sender.collected.last
|
88
|
-
end
|
89
|
-
|
90
|
-
def last_sent_notice_payload
|
91
|
-
expect(last_sent_notice_json).to_not be_nil
|
92
|
-
JSON.parse(last_sent_notice_json)
|
93
|
-
end
|
94
|
-
|
95
|
-
def build_controller(opts = {}, &action)
|
96
|
-
klass = build_controller_class do
|
97
|
-
cattr_accessor :local
|
98
|
-
define_method(:index, &action)
|
99
|
-
def local_request?
|
100
|
-
local
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
if opts[:filters]
|
105
|
-
klass.filter_parameter_logging(*opts[:filters])
|
106
|
-
end
|
107
|
-
|
108
|
-
klass.consider_all_requests_local = opts[:all_local]
|
109
|
-
klass.local = opts[:local]
|
110
|
-
controller = klass.new
|
111
|
-
controller.stub(:rescue_action_in_public_without_honeybadger)
|
112
|
-
controller
|
113
|
-
end
|
114
|
-
|
115
|
-
def process_action(opts = {}, &action)
|
116
|
-
opts[:request] ||= ActionController::TestRequest.new
|
117
|
-
opts[:response] ||= ActionController::TestResponse.new
|
118
|
-
|
119
|
-
controller = opts[:controller] || build_controller(opts, &action)
|
120
|
-
|
121
|
-
if opts[:user_agent]
|
122
|
-
if opts[:request].respond_to?(:user_agent=)
|
123
|
-
opts[:request].user_agent = opts[:user_agent]
|
124
|
-
else
|
125
|
-
opts[:request].env["HTTP_USER_AGENT"] = opts[:user_agent]
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
if opts[:port]
|
130
|
-
opts[:request].port = opts[:port]
|
131
|
-
end
|
132
|
-
|
133
|
-
opts[:request].query_parameters = opts[:request].query_parameters.merge(opts[:params] || {})
|
134
|
-
opts[:request].session = if opts.include?(:session) && opts[:session].nil?
|
135
|
-
nil
|
136
|
-
else
|
137
|
-
ActionController::TestSession.new(opts[:session] || {})
|
138
|
-
end
|
139
|
-
# Prevents request.fullpath from crashing Rails in tests
|
140
|
-
opts[:request].env['REQUEST_URI'] = opts[:request].request_uri
|
141
|
-
|
142
|
-
controller.process(opts[:request], opts[:response])
|
143
|
-
controller
|
144
|
-
end
|
145
|
-
|
146
|
-
def process_action_with_manual_notification(args = {})
|
147
|
-
process_action(args) do
|
148
|
-
notify_honeybadger(:error_message => 'fail')
|
149
|
-
# Rails will raise a template error if we don't render something
|
150
|
-
render :nothing => true
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def process_action_with_automatic_notification(args = {})
|
155
|
-
process_action(args) { raise "Hello" }
|
156
|
-
end
|
157
|
-
|
158
|
-
it "delivers notices from exceptions raised in public requests" do
|
159
|
-
process_action_with_automatic_notification
|
160
|
-
assert_caught_and_sent
|
161
|
-
end
|
162
|
-
|
163
|
-
it "not deliver notices from exceptions in local requests" do
|
164
|
-
process_action_with_automatic_notification(:local => true)
|
165
|
-
assert_caught_and_not_sent
|
166
|
-
end
|
167
|
-
|
168
|
-
it "not deliver notices from exceptions when all requests are local" do
|
169
|
-
process_action_with_automatic_notification(:all_local => true)
|
170
|
-
assert_caught_and_not_sent
|
171
|
-
end
|
172
|
-
|
173
|
-
it "not deliver notices from actions that don't raise" do
|
174
|
-
controller = process_action { render :text => 'Hello' }
|
175
|
-
assert_caught_and_not_sent
|
176
|
-
expect(controller.response.body).to eq 'Hello'
|
177
|
-
end
|
178
|
-
|
179
|
-
it "not deliver ignored exceptions raised by actions" do
|
180
|
-
ignore(RuntimeError)
|
181
|
-
process_action_with_automatic_notification
|
182
|
-
assert_caught_and_not_sent
|
183
|
-
end
|
184
|
-
|
185
|
-
it "deliver ignored exception raised manually" do
|
186
|
-
ignore(RuntimeError)
|
187
|
-
process_action_with_manual_notification
|
188
|
-
assert_caught_and_sent
|
189
|
-
end
|
190
|
-
|
191
|
-
it "deliver manually sent notices in public requests" do
|
192
|
-
process_action_with_manual_notification
|
193
|
-
assert_caught_and_sent
|
194
|
-
end
|
195
|
-
|
196
|
-
it "not deliver manually sent notices in local requests" do
|
197
|
-
process_action_with_manual_notification(:local => true)
|
198
|
-
assert_caught_and_not_sent
|
199
|
-
end
|
200
|
-
|
201
|
-
it "not deliver manually sent notices when all requests are local" do
|
202
|
-
process_action_with_manual_notification(:all_local => true)
|
203
|
-
assert_caught_and_not_sent
|
204
|
-
end
|
205
|
-
|
206
|
-
it "continue with default behavior after delivering an exception" do
|
207
|
-
controller = build_controller(:public => true) { raise 'cobras!' }
|
208
|
-
controller.should_receive(:rescue_action_in_public_without_honeybadger)
|
209
|
-
process_action(:controller => controller)
|
210
|
-
end
|
211
|
-
|
212
|
-
it "not create actions from Honeybadger methods" do
|
213
|
-
build_controller_class.new
|
214
|
-
expect(Honeybadger::Rails::ActionControllerCatcher.instance_methods).to be_empty
|
215
|
-
end
|
216
|
-
|
217
|
-
it "ignore exceptions when user agent is being ignored by regular expression" do
|
218
|
-
Honeybadger.configuration.ignore_user_agent_only = [/Ignored/]
|
219
|
-
process_action_with_automatic_notification(:user_agent => 'ShouldBeIgnored')
|
220
|
-
assert_caught_and_not_sent
|
221
|
-
end
|
222
|
-
|
223
|
-
it "ignore exceptions when user agent is being ignored by string" do
|
224
|
-
Honeybadger.configuration.ignore_user_agent_only = ['IgnoredUserAgent']
|
225
|
-
process_action_with_automatic_notification(:user_agent => 'IgnoredUserAgent')
|
226
|
-
assert_caught_and_not_sent
|
227
|
-
end
|
228
|
-
|
229
|
-
it "not ignore exceptions when user agent is not being ignored" do
|
230
|
-
Honeybadger.configuration.ignore_user_agent_only = ['IgnoredUserAgent']
|
231
|
-
process_action_with_automatic_notification(:user_agent => 'NonIgnoredAgent')
|
232
|
-
assert_caught_and_sent
|
233
|
-
end
|
234
|
-
|
235
|
-
it "send session data for manual notifications" do
|
236
|
-
data = { 'one' => 'two' }
|
237
|
-
process_action_with_manual_notification(:session => data)
|
238
|
-
assert_sent_hash(data) { |h| h['request']['session'] }
|
239
|
-
end
|
240
|
-
|
241
|
-
it "send session data for automatic notification" do
|
242
|
-
data = { 'one' => 'two' }
|
243
|
-
process_action_with_automatic_notification(:session => data)
|
244
|
-
assert_sent_hash(data) { |h| h['request']['session'] }
|
245
|
-
end
|
246
|
-
|
247
|
-
it "fails gracefully when session isn nil" do
|
248
|
-
process_action_with_automatic_notification(:session => nil)
|
249
|
-
assert_sent_hash({}) { |h| h['request']['session'] }
|
250
|
-
end
|
251
|
-
|
252
|
-
it "send request data for manual notification" do
|
253
|
-
params = { 'controller' => "honeybadger_test", 'action' => "index" }
|
254
|
-
controller = process_action_with_manual_notification(:params => params)
|
255
|
-
assert_sent_request_info_for controller.request
|
256
|
-
end
|
257
|
-
|
258
|
-
it "send request data for manual notification with non-standard port" do
|
259
|
-
params = { 'controller' => "honeybadger_test", 'action' => "index" }
|
260
|
-
controller = process_action_with_manual_notification(:params => params, :port => 81)
|
261
|
-
assert_sent_request_info_for controller.request
|
262
|
-
end
|
263
|
-
|
264
|
-
it "send request data for automatic notification" do
|
265
|
-
params = { 'controller' => "honeybadger_test", 'action' => "index" }
|
266
|
-
controller = process_action_with_automatic_notification(:params => params)
|
267
|
-
assert_sent_request_info_for controller.request
|
268
|
-
end
|
269
|
-
|
270
|
-
it "send request data for automatic notification with non-standard port" do
|
271
|
-
params = { 'controller' => "honeybadger_test", 'action' => "index" }
|
272
|
-
controller = process_action_with_automatic_notification(:params => params, :port => 81)
|
273
|
-
assert_sent_request_info_for controller.request
|
274
|
-
end
|
275
|
-
|
276
|
-
it "use standard rails logging filters on params and session and env" do
|
277
|
-
filtered_params = { "abc" => "123",
|
278
|
-
"def" => "456",
|
279
|
-
"ghi" => "[FILTERED]" }
|
280
|
-
filtered_session = { "abc" => "123",
|
281
|
-
"ghi" => "[FILTERED]" }
|
282
|
-
ENV['ghi'] = 'abc'
|
283
|
-
filtered_env = { 'ghi' => '[FILTERED]' }
|
284
|
-
filtered_cgi = { 'REQUEST_METHOD' => '[FILTERED]' }
|
285
|
-
|
286
|
-
process_action_with_automatic_notification(:filters => [:ghi, :request_method],
|
287
|
-
:params => { "abc" => "123",
|
288
|
-
"def" => "456",
|
289
|
-
"ghi" => "789" },
|
290
|
-
:session => { "abc" => "123",
|
291
|
-
"ghi" => "789" })
|
292
|
-
assert_sent_hash(filtered_params) { |h| h['request']['params'] }
|
293
|
-
assert_sent_hash(filtered_cgi) { |h| h['request']['cgi_data'] }
|
294
|
-
assert_sent_hash(filtered_session) { |h| h['request']['session'] }
|
295
|
-
end
|
296
|
-
|
297
|
-
it "call session.to_hash if available" do
|
298
|
-
hash_data = {:key => :value}
|
299
|
-
|
300
|
-
session = ActionController::TestSession.new
|
301
|
-
ActionController::TestSession.stub(:new).and_return(session)
|
302
|
-
session.stub(:to_hash).and_return(hash_data)
|
303
|
-
|
304
|
-
session.should_receive(:to_hash)
|
305
|
-
session.should_receive(:data).never
|
306
|
-
|
307
|
-
process_action_with_automatic_notification
|
308
|
-
assert_caught_and_sent
|
309
|
-
end
|
310
|
-
|
311
|
-
it "call session.data if session.to_hash is undefined" do
|
312
|
-
hash_data = {:key => :value}
|
313
|
-
|
314
|
-
session = ActionController::TestSession.new
|
315
|
-
ActionController::TestSession.stub(:new).and_return(session)
|
316
|
-
session.stub(:data).and_return(hash_data)
|
317
|
-
session.stub(:respond_to?).with(:to_hash).and_return(false)
|
318
|
-
|
319
|
-
session.should_receive(:to_hash).never
|
320
|
-
session.should_receive(:data).at_least(1).times
|
321
|
-
|
322
|
-
process_action_with_automatic_notification
|
323
|
-
assert_caught_and_sent
|
324
|
-
end
|
325
|
-
end
|
326
|
-
rescue LoadError
|
327
|
-
nil
|
328
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# This test should be run only when Rails is not bundled
|
4
|
-
require 'honeybadger/rails' unless defined?(ActionController::Base)
|
5
|
-
|
6
|
-
describe 'Honeybadger::Rails', :unless => defined?(ActionController::Base) do
|
7
|
-
include DefinesConstants
|
8
|
-
|
9
|
-
it "triggers use of Rails' logger if logger isn't set and Rails' logger exists" do
|
10
|
-
rails = Module.new do
|
11
|
-
def self.logger
|
12
|
-
"RAILS LOGGER"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
define_constant("Rails", rails)
|
16
|
-
Honeybadger::Rails.initialize
|
17
|
-
expect(Honeybadger.logger).to eq "RAILS LOGGER"
|
18
|
-
end
|
19
|
-
|
20
|
-
it "triggers use of Rails' default logger if logger isn't set and Rails.logger doesn't exist" do
|
21
|
-
define_constant("RAILS_DEFAULT_LOGGER", "RAILS DEFAULT LOGGER")
|
22
|
-
|
23
|
-
Honeybadger::Rails.initialize
|
24
|
-
expect(Honeybadger.logger).to eq "RAILS DEFAULT LOGGER"
|
25
|
-
end
|
26
|
-
|
27
|
-
it "allows overriding of the logger if already assigned" do
|
28
|
-
define_constant("RAILS_DEFAULT_LOGGER", "RAILS DEFAULT LOGGER")
|
29
|
-
Honeybadger::Rails.initialize
|
30
|
-
|
31
|
-
Honeybadger.configure(true) do |config|
|
32
|
-
config.logger = "OVERRIDDEN LOGGER"
|
33
|
-
end
|
34
|
-
|
35
|
-
expect(Honeybadger.logger).to eq "OVERRIDDEN LOGGER"
|
36
|
-
end
|
37
|
-
end
|