raygun4ruby 3.2.0 → 3.2.5.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +21 -18
- data/.rspec +1 -1
- data/.travis.yml +20 -12
- data/CHANGELOG.md +130 -117
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +420 -420
- data/Rakefile +27 -27
- data/examples/sinatras_raygun.rb +17 -17
- data/lib/generators/raygun/install_generator.rb +26 -26
- data/lib/raygun.rb +179 -179
- data/lib/raygun/affected_user.rb +59 -59
- data/lib/raygun/breadcrumbs.rb +34 -34
- data/lib/raygun/breadcrumbs/breadcrumb.rb +34 -34
- data/lib/raygun/breadcrumbs/store.rb +86 -86
- data/lib/raygun/client.rb +308 -303
- data/lib/raygun/configuration.rb +194 -194
- data/lib/raygun/error.rb +10 -10
- data/lib/raygun/javascript_tracker.rb +42 -42
- data/lib/raygun/middleware/breadcrumbs_store_initializer.rb +19 -19
- data/lib/raygun/middleware/javascript_exception_tracking.rb +32 -32
- data/lib/raygun/middleware/rack_exception_interceptor.rb +18 -18
- data/lib/raygun/middleware/rails_insert_affected_user.rb +26 -26
- data/lib/raygun/railtie.rb +39 -39
- data/lib/raygun/services/apply_whitelist_filter_to_payload.rb +27 -27
- data/lib/raygun/sidekiq.rb +71 -67
- data/lib/raygun/version.rb +3 -3
- data/lib/raygun4ruby.rb +1 -1
- data/lib/resque/failure/raygun.rb +25 -25
- data/lib/tasks/raygun.tasks +7 -7
- data/raygun4ruby.gemspec +45 -45
- data/spec/dummy/.gitignore +17 -0
- data/spec/dummy/Gemfile +47 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -6
- data/spec/dummy/app/assets/config/manifest.js +3 -3
- data/spec/dummy/app/assets/javascripts/application.js +13 -15
- data/spec/dummy/app/assets/stylesheets/application.css +15 -15
- data/spec/dummy/app/controllers/application_controller.rb +5 -2
- data/spec/dummy/app/controllers/home_controller.rb +4 -4
- data/spec/dummy/app/helpers/application_helper.rb +2 -2
- data/spec/dummy/app/{assets/javascripts/channels → mailers}/.keep +0 -0
- data/spec/dummy/{storage → app/models}/.keep +0 -0
- data/spec/dummy/app/views/home/index.html.erb +3 -3
- data/spec/dummy/app/views/home/index.json.erb +1 -1
- data/spec/dummy/app/views/layouts/application.html.erb +14 -15
- data/spec/dummy/bin/bundle +3 -3
- data/spec/dummy/bin/rails +9 -4
- data/spec/dummy/bin/rake +9 -4
- data/spec/dummy/bin/setup +29 -36
- data/spec/dummy/bin/spring +17 -0
- data/spec/dummy/config.ru +4 -5
- data/spec/dummy/config/application.rb +26 -18
- data/spec/dummy/config/boot.rb +3 -5
- data/spec/dummy/config/database.yml +25 -25
- data/spec/dummy/config/environment.rb +5 -5
- data/spec/dummy/config/environments/development.rb +41 -61
- data/spec/dummy/config/environments/production.rb +79 -94
- data/spec/dummy/config/initializers/assets.rb +11 -14
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -5
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
- data/spec/dummy/config/initializers/inflections.rb +16 -16
- data/spec/dummy/config/initializers/mime_types.rb +4 -4
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/to_time_preserves_timezone.rb +10 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
- data/spec/dummy/config/locales/en.yml +23 -33
- data/spec/dummy/config/routes.rb +58 -3
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/{db/test.sqlite3 → lib/tasks/.keep} +0 -0
- data/spec/dummy/public/404.html +67 -67
- data/spec/dummy/public/422.html +67 -67
- data/spec/dummy/public/500.html +66 -66
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/dummy/{public/apple-touch-icon-precomposed.png → vendor/assets/javascripts/.keep} +0 -0
- data/spec/dummy/{public/apple-touch-icon.png → vendor/assets/stylesheets/.keep} +0 -0
- data/spec/features/javascript_spec.rb +48 -48
- data/spec/rails_helper.rb +4 -4
- data/spec/raygun/breadcrumbs/breadcrumb_spec.rb +171 -171
- data/spec/raygun/breadcrumbs/store_spec.rb +170 -170
- data/spec/raygun/raygun_spec.rb +47 -47
- data/spec/services/apply_whitelist_filter_to_payload_spec.rb +251 -251
- data/spec/spec_helper.rb +24 -24
- data/spec/support/fake_logger.rb +17 -17
- data/test/integration/client_test.rb +19 -19
- data/test/test_helper.rb +72 -72
- data/test/unit/affected_user_test.rb +136 -136
- data/test/unit/client_test.rb +812 -790
- data/test/unit/configuration_test.rb +206 -206
- data/test/unit/raygun_test.rb +25 -25
- data/test/unit/resque_failure_test.rb +24 -24
- data/test/unit/sidekiq_failure_test.rb +32 -32
- metadata +36 -49
- data/lib/raygun/testable.rb +0 -23
- data/spec/dummy/.ruby-version +0 -1
- data/spec/dummy/app/assets/javascripts/cable.js +0 -13
- data/spec/dummy/app/channels/application_cable/channel.rb +0 -4
- data/spec/dummy/app/channels/application_cable/connection.rb +0 -4
- data/spec/dummy/app/jobs/application_job.rb +0 -2
- data/spec/dummy/app/mailers/application_mailer.rb +0 -4
- data/spec/dummy/app/models/application_record.rb +0 -3
- data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
- data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
- data/spec/dummy/bin/update +0 -31
- data/spec/dummy/bin/yarn +0 -11
- data/spec/dummy/config/cable.yml +0 -10
- data/spec/dummy/config/environments/test.rb +0 -46
- data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -8
- data/spec/dummy/config/initializers/content_security_policy.rb +0 -25
- data/spec/dummy/config/puma.rb +0 -34
- data/spec/dummy/config/spring.rb +0 -6
- data/spec/dummy/config/storage.yml +0 -34
- data/spec/dummy/db/schema.rb +0 -15
- data/spec/dummy/package.json +0 -5
data/spec/dummy/public/500.html
CHANGED
@@ -1,66 +1,66 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body
|
58
|
-
<!-- This file lives in public/500.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>We're sorry, but something went wrong.</h1>
|
62
|
-
</div>
|
63
|
-
<p>If you are the application owner check the logs for more information.</p>
|
64
|
-
</div>
|
65
|
-
</body>
|
66
|
-
</html>
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
File without changes
|
File without changes
|
@@ -1,48 +1,48 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
feature 'JavaScript Tracking', feature: true do
|
4
|
-
before { Raygun.configuration.js_api_key = nil }
|
5
|
-
after { Raygun.configuration.js_api_key = nil }
|
6
|
-
|
7
|
-
it "Includes the Raygun Javascript Middleware" do
|
8
|
-
expect(Rails.application.config.middleware).to include(Raygun::Middleware::JavascriptExceptionTracking)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "Does not inject the JS snippet" do
|
12
|
-
visit root_path
|
13
|
-
|
14
|
-
expect(page.html).to_not include('cdn.raygun.io/raygun4js/raygun.min.js')
|
15
|
-
expect(page.html).to_not include('rg4js(')
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'With a JS API Key' do
|
19
|
-
before { Raygun.configuration.js_api_key = 'Sample key' }
|
20
|
-
|
21
|
-
it "Injects the JS snippet" do
|
22
|
-
visit root_path
|
23
|
-
|
24
|
-
expect(page.html).to include('cdn.raygun.io/raygun4js/raygun.min.js')
|
25
|
-
expect(page.html).to include('rg4js(')
|
26
|
-
end
|
27
|
-
|
28
|
-
it "Does not inject the JS snippet" do
|
29
|
-
visit root_path(format: :json)
|
30
|
-
|
31
|
-
expect(page.html).to_not include('cdn.raygun.io/raygun4js/raygun.min.js')
|
32
|
-
expect(page.html).to_not include('rg4js(')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "With JS version overriden" do
|
37
|
-
before do
|
38
|
-
Raygun.configuration.js_api_version = "2.14.1"
|
39
|
-
Raygun.configuration.js_api_key = "Sample key"
|
40
|
-
end
|
41
|
-
|
42
|
-
it "Uses the overriden version" do
|
43
|
-
visit root_path
|
44
|
-
|
45
|
-
expect(page.html).to include('cdn.raygun.io/raygun4js/2.14.1/raygun.min.js')
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
feature 'JavaScript Tracking', feature: true do
|
4
|
+
before { Raygun.configuration.js_api_key = nil }
|
5
|
+
after { Raygun.configuration.js_api_key = nil }
|
6
|
+
|
7
|
+
it "Includes the Raygun Javascript Middleware" do
|
8
|
+
expect(Rails.application.config.middleware).to include(Raygun::Middleware::JavascriptExceptionTracking)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "Does not inject the JS snippet" do
|
12
|
+
visit root_path
|
13
|
+
|
14
|
+
expect(page.html).to_not include('cdn.raygun.io/raygun4js/raygun.min.js')
|
15
|
+
expect(page.html).to_not include('rg4js(')
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'With a JS API Key' do
|
19
|
+
before { Raygun.configuration.js_api_key = 'Sample key' }
|
20
|
+
|
21
|
+
it "Injects the JS snippet" do
|
22
|
+
visit root_path
|
23
|
+
|
24
|
+
expect(page.html).to include('cdn.raygun.io/raygun4js/raygun.min.js')
|
25
|
+
expect(page.html).to include('rg4js(')
|
26
|
+
end
|
27
|
+
|
28
|
+
it "Does not inject the JS snippet" do
|
29
|
+
visit root_path(format: :json)
|
30
|
+
|
31
|
+
expect(page.html).to_not include('cdn.raygun.io/raygun4js/raygun.min.js')
|
32
|
+
expect(page.html).to_not include('rg4js(')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "With JS version overriden" do
|
37
|
+
before do
|
38
|
+
Raygun.configuration.js_api_version = "2.14.1"
|
39
|
+
Raygun.configuration.js_api_key = "Sample key"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "Uses the overriden version" do
|
43
|
+
visit root_path
|
44
|
+
|
45
|
+
expect(page.html).to include('cdn.raygun.io/raygun4js/2.14.1/raygun.min.js')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/spec/rails_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
ENV['RAILS_ENV'] ||= 'test'
|
2
|
-
require 'dummy/config/environment'
|
3
|
-
|
4
|
-
require 'rspec/rails'
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
require 'dummy/config/environment'
|
3
|
+
|
4
|
+
require 'rspec/rails'
|
@@ -1,171 +1,171 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module Raygun
|
4
|
-
module Breadcrumbs
|
5
|
-
describe Breadcrumb do
|
6
|
-
let(:subject) { Breadcrumb.new }
|
7
|
-
context 'fields' do
|
8
|
-
it 'has a message' do
|
9
|
-
message = 'foo'
|
10
|
-
|
11
|
-
subject.message = message
|
12
|
-
|
13
|
-
expect(subject.message).to eq(message)
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'has a category' do
|
17
|
-
category = 'foo'
|
18
|
-
|
19
|
-
subject.category = category
|
20
|
-
|
21
|
-
expect(subject.category).to eq(category)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'has a level' do
|
25
|
-
level = 'foo'
|
26
|
-
|
27
|
-
subject.level = level
|
28
|
-
|
29
|
-
expect(subject.level).to eq(level)
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'has a timestamp' do
|
33
|
-
timestamp = Time.now
|
34
|
-
|
35
|
-
subject.timestamp = timestamp
|
36
|
-
|
37
|
-
expect(subject.timestamp).to eq(timestamp)
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'has metadata' do
|
41
|
-
metadata = {foo: '1'}
|
42
|
-
|
43
|
-
subject.metadata = metadata
|
44
|
-
|
45
|
-
expect(subject.metadata).to eq(metadata)
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'has a class_name' do
|
49
|
-
class_name = 'foo'
|
50
|
-
|
51
|
-
subject.class_name = class_name
|
52
|
-
|
53
|
-
expect(subject.class_name).to eq(class_name)
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'has a method_name' do
|
57
|
-
method_name = 'foo'
|
58
|
-
|
59
|
-
subject.method_name = method_name
|
60
|
-
|
61
|
-
expect(subject.method_name).to eq(method_name)
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'has a line_number' do
|
65
|
-
line_number = 17
|
66
|
-
|
67
|
-
subject.line_number = line_number
|
68
|
-
|
69
|
-
expect(subject.line_number).to eq(line_number)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "#build_payload" do
|
74
|
-
before do
|
75
|
-
Timecop.freeze
|
76
|
-
Store.initialize
|
77
|
-
end
|
78
|
-
after do
|
79
|
-
Timecop.return
|
80
|
-
Store.clear
|
81
|
-
end
|
82
|
-
|
83
|
-
let(:breadcrumb) do
|
84
|
-
Store.record(
|
85
|
-
message: "test",
|
86
|
-
category: "test",
|
87
|
-
level: :info,
|
88
|
-
class_name: "HomeController",
|
89
|
-
method_name: "index",
|
90
|
-
line_number: 17,
|
91
|
-
metadata: {
|
92
|
-
foo: 'bar'
|
93
|
-
}
|
94
|
-
)
|
95
|
-
|
96
|
-
Store.stored[0]
|
97
|
-
end
|
98
|
-
let(:payload) { breadcrumb.build_payload }
|
99
|
-
|
100
|
-
it "joins the class name, method name and line number together" do
|
101
|
-
expect(payload[:location]).to eq("HomeController:index:17")
|
102
|
-
end
|
103
|
-
|
104
|
-
it "does not include the method name and line number if the class name is missing" do
|
105
|
-
breadcrumb.class_name = nil
|
106
|
-
|
107
|
-
expect(payload.has_key?(:location)).to eq(false)
|
108
|
-
end
|
109
|
-
|
110
|
-
it "does not inlcude the line number if is it missing" do
|
111
|
-
breadcrumb.line_number = nil
|
112
|
-
|
113
|
-
expect(payload[:location]).to eq("HomeController:index")
|
114
|
-
end
|
115
|
-
|
116
|
-
it "does not include keys in payload with nil values" do
|
117
|
-
breadcrumb.metadata = nil
|
118
|
-
breadcrumb.category = nil
|
119
|
-
|
120
|
-
expect(payload.key?(:CustomData)).to eq(false)
|
121
|
-
expect(payload.key?(:category)).to eq(false)
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'includes the rest of the fields' do
|
125
|
-
expect(payload[:message]).to eq('test')
|
126
|
-
expect(payload[:category]).to eq('test')
|
127
|
-
expect(payload[:level]).to eq(1)
|
128
|
-
expect(payload[:timestamp]).to_not eq(nil)
|
129
|
-
expect(payload[:CustomData]).to eq(foo: 'bar')
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
describe "#size" do
|
134
|
-
before do
|
135
|
-
Timecop.freeze
|
136
|
-
Store.initialize
|
137
|
-
end
|
138
|
-
after do
|
139
|
-
Timecop.return
|
140
|
-
Store.clear
|
141
|
-
end
|
142
|
-
|
143
|
-
let(:message) { "This is a breadcrumb message" }
|
144
|
-
|
145
|
-
let(:breadcrumb) do
|
146
|
-
Store.record(
|
147
|
-
message: message,
|
148
|
-
category: "test",
|
149
|
-
level: :info,
|
150
|
-
class_name: "HomeController",
|
151
|
-
method_name: "index",
|
152
|
-
line_number: 17,
|
153
|
-
metadata: {
|
154
|
-
foo: 'bar'
|
155
|
-
}
|
156
|
-
)
|
157
|
-
|
158
|
-
Store.stored[0]
|
159
|
-
end
|
160
|
-
|
161
|
-
let(:size) { breadcrumb.size }
|
162
|
-
|
163
|
-
it "returns the estimated size of the breadcrumb" do
|
164
|
-
# Can't check all the fields but message so assume a standard 100 length for all of them
|
165
|
-
# The message should be the bulk of large breadcrumbs anyway
|
166
|
-
expect(size).to eq(message.length + 100)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Raygun
|
4
|
+
module Breadcrumbs
|
5
|
+
describe Breadcrumb do
|
6
|
+
let(:subject) { Breadcrumb.new }
|
7
|
+
context 'fields' do
|
8
|
+
it 'has a message' do
|
9
|
+
message = 'foo'
|
10
|
+
|
11
|
+
subject.message = message
|
12
|
+
|
13
|
+
expect(subject.message).to eq(message)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'has a category' do
|
17
|
+
category = 'foo'
|
18
|
+
|
19
|
+
subject.category = category
|
20
|
+
|
21
|
+
expect(subject.category).to eq(category)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'has a level' do
|
25
|
+
level = 'foo'
|
26
|
+
|
27
|
+
subject.level = level
|
28
|
+
|
29
|
+
expect(subject.level).to eq(level)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'has a timestamp' do
|
33
|
+
timestamp = Time.now
|
34
|
+
|
35
|
+
subject.timestamp = timestamp
|
36
|
+
|
37
|
+
expect(subject.timestamp).to eq(timestamp)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'has metadata' do
|
41
|
+
metadata = {foo: '1'}
|
42
|
+
|
43
|
+
subject.metadata = metadata
|
44
|
+
|
45
|
+
expect(subject.metadata).to eq(metadata)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'has a class_name' do
|
49
|
+
class_name = 'foo'
|
50
|
+
|
51
|
+
subject.class_name = class_name
|
52
|
+
|
53
|
+
expect(subject.class_name).to eq(class_name)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'has a method_name' do
|
57
|
+
method_name = 'foo'
|
58
|
+
|
59
|
+
subject.method_name = method_name
|
60
|
+
|
61
|
+
expect(subject.method_name).to eq(method_name)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'has a line_number' do
|
65
|
+
line_number = 17
|
66
|
+
|
67
|
+
subject.line_number = line_number
|
68
|
+
|
69
|
+
expect(subject.line_number).to eq(line_number)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "#build_payload" do
|
74
|
+
before do
|
75
|
+
Timecop.freeze
|
76
|
+
Store.initialize
|
77
|
+
end
|
78
|
+
after do
|
79
|
+
Timecop.return
|
80
|
+
Store.clear
|
81
|
+
end
|
82
|
+
|
83
|
+
let(:breadcrumb) do
|
84
|
+
Store.record(
|
85
|
+
message: "test",
|
86
|
+
category: "test",
|
87
|
+
level: :info,
|
88
|
+
class_name: "HomeController",
|
89
|
+
method_name: "index",
|
90
|
+
line_number: 17,
|
91
|
+
metadata: {
|
92
|
+
foo: 'bar'
|
93
|
+
}
|
94
|
+
)
|
95
|
+
|
96
|
+
Store.stored[0]
|
97
|
+
end
|
98
|
+
let(:payload) { breadcrumb.build_payload }
|
99
|
+
|
100
|
+
it "joins the class name, method name and line number together" do
|
101
|
+
expect(payload[:location]).to eq("HomeController:index:17")
|
102
|
+
end
|
103
|
+
|
104
|
+
it "does not include the method name and line number if the class name is missing" do
|
105
|
+
breadcrumb.class_name = nil
|
106
|
+
|
107
|
+
expect(payload.has_key?(:location)).to eq(false)
|
108
|
+
end
|
109
|
+
|
110
|
+
it "does not inlcude the line number if is it missing" do
|
111
|
+
breadcrumb.line_number = nil
|
112
|
+
|
113
|
+
expect(payload[:location]).to eq("HomeController:index")
|
114
|
+
end
|
115
|
+
|
116
|
+
it "does not include keys in payload with nil values" do
|
117
|
+
breadcrumb.metadata = nil
|
118
|
+
breadcrumb.category = nil
|
119
|
+
|
120
|
+
expect(payload.key?(:CustomData)).to eq(false)
|
121
|
+
expect(payload.key?(:category)).to eq(false)
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'includes the rest of the fields' do
|
125
|
+
expect(payload[:message]).to eq('test')
|
126
|
+
expect(payload[:category]).to eq('test')
|
127
|
+
expect(payload[:level]).to eq(1)
|
128
|
+
expect(payload[:timestamp]).to_not eq(nil)
|
129
|
+
expect(payload[:CustomData]).to eq(foo: 'bar')
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "#size" do
|
134
|
+
before do
|
135
|
+
Timecop.freeze
|
136
|
+
Store.initialize
|
137
|
+
end
|
138
|
+
after do
|
139
|
+
Timecop.return
|
140
|
+
Store.clear
|
141
|
+
end
|
142
|
+
|
143
|
+
let(:message) { "This is a breadcrumb message" }
|
144
|
+
|
145
|
+
let(:breadcrumb) do
|
146
|
+
Store.record(
|
147
|
+
message: message,
|
148
|
+
category: "test",
|
149
|
+
level: :info,
|
150
|
+
class_name: "HomeController",
|
151
|
+
method_name: "index",
|
152
|
+
line_number: 17,
|
153
|
+
metadata: {
|
154
|
+
foo: 'bar'
|
155
|
+
}
|
156
|
+
)
|
157
|
+
|
158
|
+
Store.stored[0]
|
159
|
+
end
|
160
|
+
|
161
|
+
let(:size) { breadcrumb.size }
|
162
|
+
|
163
|
+
it "returns the estimated size of the breadcrumb" do
|
164
|
+
# Can't check all the fields but message so assume a standard 100 length for all of them
|
165
|
+
# The message should be the bulk of large breadcrumbs anyway
|
166
|
+
expect(size).to eq(message.length + 100)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|