bugsnag 1.2.0.beta → 1.2.0
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/.rspec +3 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +14 -13
- data/Rakefile +11 -19
- data/VERSION +1 -1
- data/bugsnag.gemspec +13 -9
- data/lib/bugsnag.rb +1 -0
- data/lib/bugsnag/helpers.rb +14 -1
- data/lib/bugsnag/middleware_stack.rb +4 -1
- data/lib/bugsnag/notification.rb +14 -6
- data/lib/bugsnag/rails/controller_methods.rb +1 -5
- data/lib/bugsnag/sidekiq.rb +18 -0
- data/spec/notification_spec.rb +305 -0
- data/spec/spec_helper.rb +0 -0
- metadata +36 -33
data/.rspec
ADDED
data/Gemfile
CHANGED
@@ -8,7 +8,7 @@ gem "httparty", ">= 0.5", "< 1.0"
|
|
8
8
|
# Add dependencies to develop your gem here.
|
9
9
|
# Include everything needed to run rake, tests, features, etc.
|
10
10
|
group :development do
|
11
|
-
gem "
|
11
|
+
gem "rspec", "~> 2.11.0"
|
12
|
+
gem "rdoc"
|
12
13
|
gem "jeweler", "~> 1.6.4"
|
13
|
-
gem "rcov", ">= 0"
|
14
14
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,28 +1,29 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
i18n (~> 0.6)
|
6
|
-
multi_json (~> 1.0)
|
4
|
+
diff-lcs (1.1.3)
|
7
5
|
git (1.2.5)
|
8
6
|
httparty (0.9.0)
|
9
7
|
multi_json (~> 1.0)
|
10
8
|
multi_xml
|
11
|
-
i18n (0.6.1)
|
12
9
|
jeweler (1.6.4)
|
13
10
|
bundler (~> 1.0)
|
14
11
|
git (>= 1.2.5)
|
15
12
|
rake
|
13
|
+
json (1.7.5)
|
16
14
|
multi_json (1.3.6)
|
17
15
|
multi_xml (0.5.1)
|
18
16
|
rake (0.9.2.2)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
rdoc (3.12)
|
18
|
+
json (~> 1.4)
|
19
|
+
rspec (2.11.0)
|
20
|
+
rspec-core (~> 2.11.0)
|
21
|
+
rspec-expectations (~> 2.11.0)
|
22
|
+
rspec-mocks (~> 2.11.0)
|
23
|
+
rspec-core (2.11.1)
|
24
|
+
rspec-expectations (2.11.3)
|
25
|
+
diff-lcs (~> 1.1.3)
|
26
|
+
rspec-mocks (2.11.3)
|
26
27
|
|
27
28
|
PLATFORMS
|
28
29
|
ruby
|
@@ -31,5 +32,5 @@ DEPENDENCIES
|
|
31
32
|
httparty (>= 0.5, < 1.0)
|
32
33
|
jeweler (~> 1.6.4)
|
33
34
|
multi_json (~> 1.0)
|
34
|
-
|
35
|
-
|
35
|
+
rdoc
|
36
|
+
rspec (~> 2.11.0)
|
data/Rakefile
CHANGED
@@ -24,25 +24,8 @@ Jeweler::Tasks.new do |gem|
|
|
24
24
|
end
|
25
25
|
Jeweler::RubygemsDotOrgTasks.new
|
26
26
|
|
27
|
-
require '
|
28
|
-
|
29
|
-
test.libs << 'lib' << 'test'
|
30
|
-
test.pattern = 'test/**/test_*.rb'
|
31
|
-
test.verbose = true
|
32
|
-
end
|
33
|
-
|
34
|
-
require 'rcov/rcovtask'
|
35
|
-
Rcov::RcovTask.new do |test|
|
36
|
-
test.libs << 'test'
|
37
|
-
test.pattern = 'test/**/test_*.rb'
|
38
|
-
test.verbose = true
|
39
|
-
test.rcov_opts << '--exclude "gems/*"'
|
40
|
-
end
|
41
|
-
|
42
|
-
task :default => :test
|
43
|
-
|
44
|
-
require 'rake/rdoctask'
|
45
|
-
Rake::RDocTask.new do |rdoc|
|
27
|
+
require 'rdoc/task'
|
28
|
+
RDoc::Task.new do |rdoc|
|
46
29
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
47
30
|
|
48
31
|
rdoc.rdoc_dir = 'rdoc'
|
@@ -50,3 +33,12 @@ Rake::RDocTask.new do |rdoc|
|
|
50
33
|
rdoc.rdoc_files.include('README*')
|
51
34
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
35
|
end
|
36
|
+
|
37
|
+
# RSpec tasks
|
38
|
+
require 'rspec/core'
|
39
|
+
require "rspec/core/rake_task"
|
40
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
41
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
42
|
+
end
|
43
|
+
|
44
|
+
task :default => :spec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.0
|
1
|
+
1.2.0
|
data/bugsnag.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "bugsnag"
|
8
|
-
s.version = "1.2.0
|
8
|
+
s.version = "1.2.0"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["James Smith"]
|
12
|
-
s.date = "2012-09-
|
12
|
+
s.date = "2012-09-30"
|
13
13
|
s.description = "Ruby notifier for bugsnag.com"
|
14
14
|
s.email = "james@bugsnag.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
+
".rspec",
|
21
22
|
"Gemfile",
|
22
23
|
"Gemfile.lock",
|
23
24
|
"LICENSE.txt",
|
@@ -41,11 +42,14 @@ Gem::Specification.new do |s|
|
|
41
42
|
"lib/bugsnag/rails/action_controller_rescue.rb",
|
42
43
|
"lib/bugsnag/rails/controller_methods.rb",
|
43
44
|
"lib/bugsnag/railtie.rb",
|
45
|
+
"lib/bugsnag/sidekiq.rb",
|
44
46
|
"lib/bugsnag/tasks.rb",
|
45
47
|
"lib/bugsnag/tasks/bugsnag.rake",
|
46
48
|
"lib/bugsnag/version.rb",
|
47
49
|
"lib/resque/failure/bugsnag.rb",
|
48
50
|
"rails/init.rb",
|
51
|
+
"spec/notification_spec.rb",
|
52
|
+
"spec/spec_helper.rb",
|
49
53
|
"test/helper.rb",
|
50
54
|
"test/test_bugsnag.rb"
|
51
55
|
]
|
@@ -61,22 +65,22 @@ Gem::Specification.new do |s|
|
|
61
65
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
62
66
|
s.add_runtime_dependency(%q<multi_json>, ["~> 1.0"])
|
63
67
|
s.add_runtime_dependency(%q<httparty>, ["< 1.0", ">= 0.5"])
|
64
|
-
s.add_development_dependency(%q<
|
68
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.11.0"])
|
69
|
+
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
65
70
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
66
|
-
s.add_development_dependency(%q<rcov>, [">= 0"])
|
67
71
|
else
|
68
72
|
s.add_dependency(%q<multi_json>, ["~> 1.0"])
|
69
73
|
s.add_dependency(%q<httparty>, ["< 1.0", ">= 0.5"])
|
70
|
-
s.add_dependency(%q<
|
74
|
+
s.add_dependency(%q<rspec>, ["~> 2.11.0"])
|
75
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
71
76
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
72
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
73
77
|
end
|
74
78
|
else
|
75
79
|
s.add_dependency(%q<multi_json>, ["~> 1.0"])
|
76
80
|
s.add_dependency(%q<httparty>, ["< 1.0", ">= 0.5"])
|
77
|
-
s.add_dependency(%q<
|
81
|
+
s.add_dependency(%q<rspec>, ["~> 2.11.0"])
|
82
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
78
83
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
79
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
80
84
|
end
|
81
85
|
end
|
82
86
|
|
data/lib/bugsnag.rb
CHANGED
data/lib/bugsnag/helpers.rb
CHANGED
@@ -37,13 +37,26 @@ module Bugsnag
|
|
37
37
|
hash.inject({}) do |h, (k,v)|
|
38
38
|
if v.is_a?(Hash)
|
39
39
|
h[k] = reduce_hash_size(v)
|
40
|
+
elsif v.is_a?(Array) || v.is_a?(Set)
|
41
|
+
h[k] = v.map {|el| reduce_hash_size(el) }
|
40
42
|
else
|
41
|
-
h[k] = v.to_s.slice(0, MAX_STRING_LENGTH)
|
43
|
+
h[k] = v.to_s.slice(0, MAX_STRING_LENGTH) + "[TRUNCATED]"
|
42
44
|
end
|
43
45
|
|
44
46
|
h
|
45
47
|
end
|
46
48
|
end
|
49
|
+
|
50
|
+
def self.flatten_meta_data(overrides)
|
51
|
+
return nil unless overrides
|
52
|
+
|
53
|
+
meta_data = overrides.delete(:meta_data)
|
54
|
+
if meta_data.is_a?(Hash)
|
55
|
+
overrides.merge(meta_data)
|
56
|
+
else
|
57
|
+
overrides
|
58
|
+
end
|
59
|
+
end
|
47
60
|
|
48
61
|
# Helper functions to work around MultiJson changes in 1.3+
|
49
62
|
def self.dump_json(object, options={})
|
@@ -43,7 +43,10 @@ module Bugsnag
|
|
43
43
|
begin
|
44
44
|
# We reverse them, so we can call "call" on the first middleware
|
45
45
|
middleware_procs.reverse.inject(notify_lambda) { |n,e| e[n] }.call(notification)
|
46
|
-
rescue
|
46
|
+
rescue StandardError => e
|
47
|
+
# KLUDGE: Since we don't re-raise middleware exceptions, this breaks rspec
|
48
|
+
raise if e.class.to_s == "RSpec::Expectations::ExpectationNotMetError"
|
49
|
+
|
47
50
|
# We dont notify, as we dont want to loop forever in the case of really broken middleware, we will
|
48
51
|
# still send this notify
|
49
52
|
Bugsnag.warn "Bugsnag middleware error: #{e}"
|
data/lib/bugsnag/notification.rb
CHANGED
@@ -10,6 +10,8 @@ module Bugsnag
|
|
10
10
|
NOTIFIER_VERSION = Bugsnag::VERSION
|
11
11
|
NOTIFIER_URL = "http://www.bugsnag.com"
|
12
12
|
|
13
|
+
API_KEY_REGEX = /[0-9a-f]{32}/i
|
14
|
+
|
13
15
|
# HTTParty settings
|
14
16
|
headers "Content-Type" => "application/json"
|
15
17
|
default_timeout 5
|
@@ -24,21 +26,24 @@ module Bugsnag
|
|
24
26
|
|
25
27
|
# If the payload is going to be too long, we trim the hashes to send
|
26
28
|
# a minimal payload instead
|
27
|
-
if payload_string.length >
|
28
|
-
payload = Bugsnag::Helpers.reduce_hash_size(
|
29
|
+
if payload_string.length > 128000
|
30
|
+
payload[:events].each {|e| e[:metaData] = Bugsnag::Helpers.reduce_hash_size(e[:metaData])}
|
29
31
|
payload_string = Bugsnag::Helpers.dump_json(payload)
|
30
32
|
end
|
31
33
|
|
32
34
|
response = post(endpoint, {:body => payload_string})
|
33
|
-
rescue
|
34
|
-
|
35
|
+
rescue StandardError => e
|
36
|
+
# KLUDGE: Since we don't re-raise http exceptions, this breaks rspec
|
37
|
+
raise if e.class.to_s == "RSpec::Expectations::ExpectationNotMetError"
|
38
|
+
|
39
|
+
Bugsnag.warn("Notification to #{endpoint} failed, #{e.inspect}")
|
35
40
|
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
39
44
|
def initialize(exception, configuration, overrides = nil, request_data = nil)
|
40
45
|
@configuration = configuration
|
41
|
-
@overrides = overrides || {}
|
46
|
+
@overrides = Bugsnag::Helpers.flatten_meta_data(overrides) || {}
|
42
47
|
@request_data = request_data
|
43
48
|
@meta_data = {}
|
44
49
|
|
@@ -89,9 +94,12 @@ module Bugsnag
|
|
89
94
|
return unless @configuration.should_notify?
|
90
95
|
|
91
96
|
# Check we have at least and api_key
|
92
|
-
|
97
|
+
if @configuration.api_key.nil?
|
93
98
|
Bugsnag.warn "No API key configured, couldn't notify"
|
94
99
|
return
|
100
|
+
elsif (@configuration.api_key =~ API_KEY_REGEX).nil?
|
101
|
+
Bugsnag.warn "Your API key (#{@configuration.api_key}) is not valid, couldn't notify"
|
102
|
+
return
|
95
103
|
end
|
96
104
|
|
97
105
|
@meta_data = {}
|
@@ -38,11 +38,7 @@ module Bugsnag::Rails
|
|
38
38
|
|
39
39
|
private
|
40
40
|
def notify_bugsnag(exception, custom_data=nil)
|
41
|
-
Bugsnag.
|
42
|
-
|
43
|
-
overrides = {}
|
44
|
-
overrides[:custom] = custom_data if custom_data
|
45
|
-
Bugsnag.notify(exception, overrides)
|
41
|
+
Bugsnag.notify(exception, custom_data)
|
46
42
|
end
|
47
43
|
end
|
48
44
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Bugsnag
|
2
|
+
class Sidekiq
|
3
|
+
def call(worker, msg, queue)
|
4
|
+
begin
|
5
|
+
yield
|
6
|
+
rescue => ex
|
7
|
+
Bugsnag.notify(ex, :meta_data => {:sidekiq => msg })
|
8
|
+
raise
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
::Sidekiq.configure_server do |config|
|
15
|
+
config.server_middleware do |chain|
|
16
|
+
chain.add ::Bugsnag::Sidekiq
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,305 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'bugsnag'
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
module ActiveRecord; class RecordNotFound < RuntimeError; end; end
|
6
|
+
class BugsnagTestException < RuntimeError; end
|
7
|
+
|
8
|
+
def get_event_from_payload(payload)
|
9
|
+
payload[:events].should have(1).items
|
10
|
+
payload[:events].first
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_exception_from_payload(payload)
|
14
|
+
event = get_event_from_payload(payload)
|
15
|
+
event[:exceptions].should have(1).items
|
16
|
+
event[:exceptions].last
|
17
|
+
end
|
18
|
+
|
19
|
+
describe Bugsnag::Notification do
|
20
|
+
before(:each) do
|
21
|
+
Bugsnag.instance_variable_set(:@configuration, Bugsnag::Configuration.new)
|
22
|
+
Bugsnag.configure do |config|
|
23
|
+
config.api_key = "c9d60ae4c7e70c4b6c4ebd3e8056d2b8"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should contain an api_key if one is set" do
|
28
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
29
|
+
payload[:apiKey].should be == "c9d60ae4c7e70c4b6c4ebd3e8056d2b8"
|
30
|
+
end
|
31
|
+
|
32
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"))
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should not notify if api_key is not set" do
|
36
|
+
Bugsnag.configuration.api_key = nil
|
37
|
+
|
38
|
+
Bugsnag::Notification.should_not_receive(:deliver_exception_payload)
|
39
|
+
|
40
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"))
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should not notify if api_key is empty" do
|
44
|
+
Bugsnag.configuration.api_key = ""
|
45
|
+
|
46
|
+
Bugsnag::Notification.should_not_receive(:deliver_exception_payload)
|
47
|
+
|
48
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"))
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should have the right exception class" do
|
52
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
53
|
+
exception = get_exception_from_payload(payload)
|
54
|
+
exception[:errorClass].should be == "BugsnagTestException"
|
55
|
+
end
|
56
|
+
|
57
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"))
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should have the right exception message" do
|
61
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
62
|
+
exception = get_exception_from_payload(payload)
|
63
|
+
exception[:message].should be == "It crashed"
|
64
|
+
end
|
65
|
+
|
66
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"))
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should have a valid stacktrace" do
|
70
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
71
|
+
exception = get_exception_from_payload(payload)
|
72
|
+
exception[:stacktrace].length.should be > 0
|
73
|
+
end
|
74
|
+
|
75
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"))
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should accept tabs in overrides and add them to metaData" do
|
79
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
80
|
+
event = get_event_from_payload(payload)
|
81
|
+
event[:metaData][:some_tab].should_not be_nil
|
82
|
+
event[:metaData][:some_tab][:info].should be == "here"
|
83
|
+
event[:metaData][:some_tab][:data].should be == "also here"
|
84
|
+
end
|
85
|
+
|
86
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"), {
|
87
|
+
:some_tab => {
|
88
|
+
:info => "here",
|
89
|
+
:data => "also here"
|
90
|
+
}
|
91
|
+
})
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should accept non-hash overrides and add them to the custom tab in metaData" do
|
95
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
96
|
+
event = get_event_from_payload(payload)
|
97
|
+
event[:metaData][:custom].should_not be_nil
|
98
|
+
event[:metaData][:custom][:info].should be == "here"
|
99
|
+
event[:metaData][:custom][:data].should be == "also here"
|
100
|
+
end
|
101
|
+
|
102
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"), {
|
103
|
+
:info => "here",
|
104
|
+
:data => "also here"
|
105
|
+
})
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should accept meta_data in overrides (for backwards compatibility) and merge it into metaData" do
|
109
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
110
|
+
event = get_event_from_payload(payload)
|
111
|
+
event[:metaData][:some_tab].should_not be_nil
|
112
|
+
event[:metaData][:some_tab][:info].should be == "here"
|
113
|
+
event[:metaData][:some_tab][:data].should be == "also here"
|
114
|
+
end
|
115
|
+
|
116
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"), {
|
117
|
+
:meta_data => {
|
118
|
+
:some_tab => {
|
119
|
+
:info => "here",
|
120
|
+
:data => "also here"
|
121
|
+
}
|
122
|
+
}
|
123
|
+
})
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should truncate large meta_data before sending" do
|
127
|
+
Bugsnag::Notification.should_receive(:post) do |endpoint, opts|
|
128
|
+
# Truncated body should be no bigger than
|
129
|
+
# 2 truncated hashes (4096*2) + rest of payload (5000)
|
130
|
+
opts[:body].length.should be < 4096*2 + 5000
|
131
|
+
end
|
132
|
+
|
133
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"), {
|
134
|
+
:meta_data => {
|
135
|
+
:some_tab => {
|
136
|
+
:giant => SecureRandom.hex(500_000/2),
|
137
|
+
:mega => SecureRandom.hex(500_000/2)
|
138
|
+
}
|
139
|
+
}
|
140
|
+
})
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should accept a context in overrides" do
|
144
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
145
|
+
event = get_event_from_payload(payload)
|
146
|
+
event[:context].should be == "test_context"
|
147
|
+
end
|
148
|
+
|
149
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"), {
|
150
|
+
:context => "test_context"
|
151
|
+
})
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should accept a user_id in overrides" do
|
155
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
156
|
+
event = get_event_from_payload(payload)
|
157
|
+
event[:userId].should be == "test_user"
|
158
|
+
end
|
159
|
+
|
160
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"), {
|
161
|
+
:user_id => "test_user"
|
162
|
+
})
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should not send a notification if auto_notify is false" do
|
166
|
+
Bugsnag.configure do |config|
|
167
|
+
config.auto_notify = false
|
168
|
+
end
|
169
|
+
|
170
|
+
Bugsnag::Notification.should_not_receive(:deliver_exception_payload)
|
171
|
+
|
172
|
+
Bugsnag.auto_notify(BugsnagTestException.new("It crashed"))
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should contain a release_stage" do
|
176
|
+
Bugsnag.configure do |config|
|
177
|
+
config.release_stage = "production"
|
178
|
+
end
|
179
|
+
|
180
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
181
|
+
event = get_event_from_payload(payload)
|
182
|
+
event[:releaseStage].should be == "production"
|
183
|
+
end
|
184
|
+
|
185
|
+
Bugsnag.auto_notify(BugsnagTestException.new("It crashed"))
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should respect the notify_release_stages setting by not sending in development" do
|
189
|
+
Bugsnag::Notification.should_not_receive(:deliver_exception_payload)
|
190
|
+
|
191
|
+
Bugsnag.configuration.release_stage = "development"
|
192
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"))
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should respect the notify_release_stages setting when set" do
|
196
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
197
|
+
exception = get_exception_from_payload(payload)
|
198
|
+
end
|
199
|
+
|
200
|
+
Bugsnag.configuration.release_stage = "development"
|
201
|
+
Bugsnag.configuration.notify_release_stages << "development"
|
202
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"))
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should use ssl when use_ssl is true" do
|
206
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
207
|
+
endpoint.should start_with "https://"
|
208
|
+
end
|
209
|
+
|
210
|
+
Bugsnag.configuration.use_ssl = true
|
211
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"))
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should not use ssl when use_ssl is false" do
|
215
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
216
|
+
endpoint.should start_with "http://"
|
217
|
+
end
|
218
|
+
|
219
|
+
Bugsnag.configuration.use_ssl = false
|
220
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"))
|
221
|
+
end
|
222
|
+
|
223
|
+
it "should not use ssl when use_ssl is unset" do
|
224
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
225
|
+
endpoint.should start_with "http://"
|
226
|
+
end
|
227
|
+
|
228
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"))
|
229
|
+
end
|
230
|
+
|
231
|
+
it "should not mark the top-most stacktrace line as inProject if out of project" do
|
232
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
233
|
+
exception = get_exception_from_payload(payload)
|
234
|
+
exception[:stacktrace].should have_at_least(1).items
|
235
|
+
exception[:stacktrace].first[:inProject].should be_nil
|
236
|
+
end
|
237
|
+
|
238
|
+
Bugsnag.configuration.project_root = "/Random/location/here"
|
239
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"))
|
240
|
+
end
|
241
|
+
|
242
|
+
it "should mark the top-most stacktrace line as inProject if necessary" do
|
243
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
244
|
+
exception = get_exception_from_payload(payload)
|
245
|
+
exception[:stacktrace].should have_at_least(1).items
|
246
|
+
exception[:stacktrace].first[:inProject].should be == true
|
247
|
+
end
|
248
|
+
|
249
|
+
Bugsnag.configuration.project_root = File.expand_path File.dirname(__FILE__)
|
250
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"))
|
251
|
+
end
|
252
|
+
|
253
|
+
it "should add app_version to the payload if it is set" do
|
254
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
255
|
+
event = get_event_from_payload(payload)
|
256
|
+
event[:appVersion].should be == "1.1.1"
|
257
|
+
end
|
258
|
+
|
259
|
+
Bugsnag.configuration.app_version = "1.1.1"
|
260
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"))
|
261
|
+
end
|
262
|
+
|
263
|
+
it "should filter params from all payload hashes if they are set in default params_filters" do
|
264
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
265
|
+
event = get_event_from_payload(payload)
|
266
|
+
event[:metaData].should_not be_nil
|
267
|
+
event[:metaData][:request].should_not be_nil
|
268
|
+
event[:metaData][:request][:params].should_not be_nil
|
269
|
+
event[:metaData][:request][:params][:password].should be == "[FILTERED]"
|
270
|
+
event[:metaData][:request][:params][:other_password].should be == "[FILTERED]"
|
271
|
+
event[:metaData][:request][:params][:other_data].should be == "123456"
|
272
|
+
end
|
273
|
+
|
274
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"), {:request => {:params => {:password => "1234", :other_password => "12345", :other_data => "123456"}}})
|
275
|
+
end
|
276
|
+
|
277
|
+
it "should filter params from all payload hashes if they are added to params_filters" do
|
278
|
+
Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
|
279
|
+
event = get_event_from_payload(payload)
|
280
|
+
event[:metaData].should_not be_nil
|
281
|
+
event[:metaData][:request].should_not be_nil
|
282
|
+
event[:metaData][:request][:params].should_not be_nil
|
283
|
+
event[:metaData][:request][:params][:password].should be == "[FILTERED]"
|
284
|
+
event[:metaData][:request][:params][:other_password].should be == "[FILTERED]"
|
285
|
+
event[:metaData][:request][:params][:other_data].should be == "[FILTERED]"
|
286
|
+
end
|
287
|
+
|
288
|
+
Bugsnag.configuration.params_filters << "other_data"
|
289
|
+
Bugsnag.notify(BugsnagTestException.new("It crashed"), {:request => {:params => {:password => "1234", :other_password => "123456", :other_data => "123456"}}})
|
290
|
+
end
|
291
|
+
|
292
|
+
it "should not notify if the exception class is in the default ignore_classes list" do
|
293
|
+
Bugsnag::Notification.should_not_receive(:deliver_exception_payload)
|
294
|
+
|
295
|
+
Bugsnag.notify_or_ignore(ActiveRecord::RecordNotFound.new("It crashed"))
|
296
|
+
end
|
297
|
+
|
298
|
+
it "should not notify if the non-default exception class is added to the ignore_classes" do
|
299
|
+
Bugsnag.configuration.ignore_classes << "BugsnagTestException"
|
300
|
+
|
301
|
+
Bugsnag::Notification.should_not_receive(:deliver_exception_payload)
|
302
|
+
|
303
|
+
Bugsnag.notify_or_ignore(BugsnagTestException.new("It crashed"))
|
304
|
+
end
|
305
|
+
end
|
data/spec/spec_helper.rb
ADDED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bugsnag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 31
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
9
|
- 0
|
10
|
-
|
11
|
-
version: 1.2.0.beta
|
10
|
+
version: 1.2.0
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- James Smith
|
@@ -16,7 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2012-09-
|
18
|
+
date: 2012-09-30 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|
@@ -29,10 +28,10 @@ dependencies:
|
|
29
28
|
- 1
|
30
29
|
- 0
|
31
30
|
version: "1.0"
|
32
|
-
version_requirements: *id001
|
33
|
-
name: multi_json
|
34
31
|
prerelease: false
|
35
32
|
type: :runtime
|
33
|
+
name: multi_json
|
34
|
+
version_requirements: *id001
|
36
35
|
- !ruby/object:Gem::Dependency
|
37
36
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
37
|
none: false
|
@@ -51,12 +50,28 @@ dependencies:
|
|
51
50
|
- 0
|
52
51
|
- 5
|
53
52
|
version: "0.5"
|
54
|
-
version_requirements: *id002
|
55
|
-
name: httparty
|
56
53
|
prerelease: false
|
57
54
|
type: :runtime
|
55
|
+
name: httparty
|
56
|
+
version_requirements: *id002
|
58
57
|
- !ruby/object:Gem::Dependency
|
59
58
|
requirement: &id003 !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ~>
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 35
|
64
|
+
segments:
|
65
|
+
- 2
|
66
|
+
- 11
|
67
|
+
- 0
|
68
|
+
version: 2.11.0
|
69
|
+
prerelease: false
|
70
|
+
type: :development
|
71
|
+
name: rspec
|
72
|
+
version_requirements: *id003
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
60
75
|
none: false
|
61
76
|
requirements:
|
62
77
|
- - ">="
|
@@ -65,12 +80,12 @@ dependencies:
|
|
65
80
|
segments:
|
66
81
|
- 0
|
67
82
|
version: "0"
|
68
|
-
version_requirements: *id003
|
69
|
-
name: shoulda
|
70
83
|
prerelease: false
|
71
84
|
type: :development
|
85
|
+
name: rdoc
|
86
|
+
version_requirements: *id004
|
72
87
|
- !ruby/object:Gem::Dependency
|
73
|
-
requirement: &
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
74
89
|
none: false
|
75
90
|
requirements:
|
76
91
|
- - ~>
|
@@ -81,24 +96,10 @@ dependencies:
|
|
81
96
|
- 6
|
82
97
|
- 4
|
83
98
|
version: 1.6.4
|
84
|
-
version_requirements: *id004
|
85
|
-
name: jeweler
|
86
99
|
prerelease: false
|
87
100
|
type: :development
|
88
|
-
|
89
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
|
-
requirements:
|
92
|
-
- - ">="
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
hash: 3
|
95
|
-
segments:
|
96
|
-
- 0
|
97
|
-
version: "0"
|
101
|
+
name: jeweler
|
98
102
|
version_requirements: *id005
|
99
|
-
name: rcov
|
100
|
-
prerelease: false
|
101
|
-
type: :development
|
102
103
|
description: Ruby notifier for bugsnag.com
|
103
104
|
email: james@bugsnag.com
|
104
105
|
executables: []
|
@@ -110,6 +111,7 @@ extra_rdoc_files:
|
|
110
111
|
- README.md
|
111
112
|
files:
|
112
113
|
- .document
|
114
|
+
- .rspec
|
113
115
|
- Gemfile
|
114
116
|
- Gemfile.lock
|
115
117
|
- LICENSE.txt
|
@@ -133,11 +135,14 @@ files:
|
|
133
135
|
- lib/bugsnag/rails/action_controller_rescue.rb
|
134
136
|
- lib/bugsnag/rails/controller_methods.rb
|
135
137
|
- lib/bugsnag/railtie.rb
|
138
|
+
- lib/bugsnag/sidekiq.rb
|
136
139
|
- lib/bugsnag/tasks.rb
|
137
140
|
- lib/bugsnag/tasks/bugsnag.rake
|
138
141
|
- lib/bugsnag/version.rb
|
139
142
|
- lib/resque/failure/bugsnag.rb
|
140
143
|
- rails/init.rb
|
144
|
+
- spec/notification_spec.rb
|
145
|
+
- spec/spec_helper.rb
|
141
146
|
- test/helper.rb
|
142
147
|
- test/test_bugsnag.rb
|
143
148
|
homepage: http://github.com/bugsnag/bugsnag-ruby
|
@@ -160,14 +165,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
166
|
none: false
|
162
167
|
requirements:
|
163
|
-
- - "
|
168
|
+
- - ">="
|
164
169
|
- !ruby/object:Gem::Version
|
165
|
-
hash:
|
170
|
+
hash: 3
|
166
171
|
segments:
|
167
|
-
-
|
168
|
-
|
169
|
-
- 1
|
170
|
-
version: 1.3.1
|
172
|
+
- 0
|
173
|
+
version: "0"
|
171
174
|
requirements: []
|
172
175
|
|
173
176
|
rubyforge_project:
|