raygun4ruby 3.2.6 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +48 -0
- data/.gitignore +22 -21
- data/.rspec +1 -1
- data/Appraisals +19 -0
- data/CHANGELOG.md +169 -133
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +426 -420
- data/Rakefile +32 -27
- data/examples/sinatras_raygun.rb +17 -17
- data/gemfiles/rails_6.gemfile +9 -0
- data/gemfiles/rails_7.gemfile +10 -0
- data/gemfiles/rails_7_sidekiq_6.gemfile +10 -0
- data/lib/generators/raygun/install_generator.rb +26 -26
- data/lib/raygun/affected_user.rb +59 -59
- data/lib/raygun/breadcrumbs/breadcrumb.rb +34 -34
- data/lib/raygun/breadcrumbs/store.rb +86 -86
- data/lib/raygun/breadcrumbs.rb +34 -34
- data/lib/raygun/client.rb +313 -308
- data/lib/raygun/configuration.rb +198 -194
- data/lib/raygun/demo_exception.rb +22 -22
- data/lib/raygun/error.rb +10 -10
- data/lib/raygun/error_subscriber.rb +21 -0
- 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 +40 -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 +47 -39
- data/lib/raygun/services/apply_whitelist_filter_to_payload.rb +27 -27
- data/lib/raygun/sidekiq.rb +51 -71
- data/lib/raygun/version.rb +3 -3
- data/lib/raygun.rb +197 -179
- data/lib/raygun4ruby.rb +1 -1
- data/lib/resque/failure/raygun.rb +25 -25
- data/lib/tasks/raygun.tasks +7 -7
- data/raygun4ruby.gemspec +43 -45
- data/spec/features/javascript_spec.rb +48 -48
- data/spec/rails_applications/6.1.4/Gemfile +56 -0
- data/spec/{dummy/README.rdoc → rails_applications/6.1.4/README.md} +24 -28
- data/spec/{dummy → rails_applications/6.1.4}/Rakefile +6 -6
- data/spec/rails_applications/6.1.4/app/assets/config/manifest.js +2 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/assets/images/.keep +0 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/assets/stylesheets/application.css +15 -15
- data/spec/rails_applications/6.1.4/app/channels/application_cable/channel.rb +4 -0
- data/spec/rails_applications/6.1.4/app/channels/application_cable/connection.rb +4 -0
- data/spec/rails_applications/6.1.4/app/controllers/application_controller.rb +2 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/controllers/concerns/.keep +0 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/controllers/home_controller.rb +4 -4
- data/spec/{dummy → rails_applications/6.1.4}/app/helpers/application_helper.rb +2 -2
- data/spec/rails_applications/6.1.4/app/javascript/channels/consumer.js +6 -0
- data/spec/rails_applications/6.1.4/app/javascript/channels/index.js +5 -0
- data/spec/rails_applications/6.1.4/app/javascript/packs/application.js +13 -0
- data/spec/rails_applications/6.1.4/app/jobs/application_job.rb +7 -0
- data/spec/rails_applications/6.1.4/app/mailers/application_mailer.rb +4 -0
- data/spec/rails_applications/6.1.4/app/models/application_record.rb +3 -0
- data/spec/{dummy/app/mailers → rails_applications/6.1.4/app/models/concerns}/.keep +0 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/views/home/index.html.erb +3 -3
- data/spec/{dummy → rails_applications/6.1.4}/app/views/home/index.json.erb +1 -1
- data/spec/rails_applications/6.1.4/app/views/layouts/application.html.erb +13 -0
- data/spec/rails_applications/6.1.4/app/views/layouts/mailer.html.erb +13 -0
- data/spec/rails_applications/6.1.4/app/views/layouts/mailer.text.erb +1 -0
- data/spec/rails_applications/6.1.4/bin/rails +5 -0
- data/spec/rails_applications/6.1.4/bin/rake +5 -0
- data/spec/rails_applications/6.1.4/bin/setup +36 -0
- data/spec/rails_applications/6.1.4/bin/spring +14 -0
- data/spec/rails_applications/6.1.4/bin/yarn +17 -0
- data/spec/rails_applications/6.1.4/config/application.rb +22 -0
- data/spec/rails_applications/6.1.4/config/boot.rb +3 -0
- data/spec/rails_applications/6.1.4/config/cable.yml +10 -0
- data/spec/rails_applications/6.1.4/config/credentials.yml.enc +1 -0
- data/spec/{dummy → rails_applications/6.1.4}/config/database.yml +25 -25
- data/spec/{dummy → rails_applications/6.1.4}/config/environment.rb +5 -5
- data/spec/rails_applications/6.1.4/config/environments/development.rb +76 -0
- data/spec/rails_applications/6.1.4/config/environments/production.rb +120 -0
- data/spec/rails_applications/6.1.4/config/environments/test.rb +60 -0
- data/spec/rails_applications/6.1.4/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/rails_applications/6.1.4/config/initializers/assets.rb +14 -0
- data/spec/rails_applications/6.1.4/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/rails_applications/6.1.4/config/initializers/content_security_policy.rb +30 -0
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/cookies_serializer.rb +5 -3
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/filter_parameter_logging.rb +6 -4
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/inflections.rb +16 -16
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/mime_types.rb +4 -4
- data/spec/rails_applications/6.1.4/config/initializers/permissions_policy.rb +11 -0
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/wrap_parameters.rb +14 -14
- data/spec/{dummy → rails_applications/6.1.4}/config/locales/en.yml +33 -23
- data/spec/rails_applications/6.1.4/config/master.key +1 -0
- data/spec/rails_applications/6.1.4/config/puma.rb +43 -0
- data/spec/rails_applications/6.1.4/config/routes.rb +4 -0
- data/spec/rails_applications/6.1.4/config/spring.rb +6 -0
- data/spec/rails_applications/6.1.4/config/storage.yml +34 -0
- data/spec/{dummy → rails_applications/6.1.4}/config.ru +6 -4
- data/spec/rails_applications/6.1.4/db/seeds.rb +7 -0
- data/spec/{dummy → rails_applications/6.1.4}/db/test.sqlite3 +0 -0
- data/spec/{dummy/app/models → rails_applications/6.1.4/lib/assets}/.keep +0 -0
- data/spec/{dummy/app/models/concerns → rails_applications/6.1.4/lib/tasks}/.keep +0 -0
- data/spec/rails_applications/6.1.4/package.json +11 -0
- data/spec/{dummy → rails_applications/6.1.4}/public/404.html +67 -67
- data/spec/{dummy → rails_applications/6.1.4}/public/422.html +67 -67
- data/spec/{dummy → rails_applications/6.1.4}/public/500.html +66 -66
- data/spec/{dummy/lib/assets/.keep → rails_applications/6.1.4/public/apple-touch-icon-precomposed.png} +0 -0
- data/spec/{dummy/lib/tasks/.keep → rails_applications/6.1.4/public/apple-touch-icon.png} +0 -0
- data/spec/{dummy → rails_applications/6.1.4}/public/favicon.ico +0 -0
- data/spec/rails_applications/6.1.4/public/robots.txt +1 -0
- data/spec/{dummy/log → rails_applications/6.1.4/storage}/.keep +0 -0
- data/spec/rails_applications/7.1.3/.dockerignore +37 -0
- data/spec/rails_applications/7.1.3/.gitattributes +9 -0
- data/spec/rails_applications/7.1.3/.gitignore +35 -0
- data/spec/rails_applications/7.1.3/.ruby-version +1 -0
- data/spec/rails_applications/7.1.3/Dockerfile +62 -0
- data/spec/rails_applications/7.1.3/Gemfile +67 -0
- data/spec/rails_applications/7.1.3/README.md +24 -0
- data/spec/rails_applications/7.1.3/Rakefile +6 -0
- data/spec/rails_applications/7.1.3/app/assets/config/manifest.js +4 -0
- data/spec/{dummy/test/controllers → rails_applications/7.1.3/app/assets/images}/.keep +0 -0
- data/spec/rails_applications/7.1.3/app/assets/stylesheets/application.css +15 -0
- data/spec/rails_applications/7.1.3/app/channels/application_cable/channel.rb +4 -0
- data/spec/rails_applications/7.1.3/app/channels/application_cable/connection.rb +4 -0
- data/spec/rails_applications/7.1.3/app/controllers/application_controller.rb +2 -0
- data/spec/{dummy/test/fixtures → rails_applications/7.1.3/app/controllers/concerns}/.keep +0 -0
- data/spec/rails_applications/7.1.3/app/controllers/home_controller.rb +2 -0
- data/spec/rails_applications/7.1.3/app/helpers/application_helper.rb +2 -0
- data/spec/rails_applications/7.1.3/app/helpers/home_helper.rb +2 -0
- data/spec/rails_applications/7.1.3/app/javascript/application.js +3 -0
- data/spec/rails_applications/7.1.3/app/javascript/controllers/application.js +9 -0
- data/spec/rails_applications/7.1.3/app/javascript/controllers/hello_controller.js +7 -0
- data/spec/rails_applications/7.1.3/app/javascript/controllers/index.js +11 -0
- data/spec/rails_applications/7.1.3/app/jobs/application_job.rb +7 -0
- data/spec/rails_applications/7.1.3/app/mailers/application_mailer.rb +4 -0
- data/spec/rails_applications/7.1.3/app/models/application_record.rb +3 -0
- data/spec/{dummy/test/helpers → rails_applications/7.1.3/app/models/concerns}/.keep +0 -0
- data/spec/rails_applications/7.1.3/app/views/home/index.html.erb +3 -0
- data/spec/rails_applications/7.1.3/app/views/home/index.json.erb +1 -0
- data/spec/rails_applications/7.1.3/app/views/layouts/application.html.erb +16 -0
- data/spec/rails_applications/7.1.3/app/views/layouts/mailer.html.erb +13 -0
- data/spec/rails_applications/7.1.3/app/views/layouts/mailer.text.erb +1 -0
- data/spec/rails_applications/7.1.3/bin/bundle +109 -0
- data/spec/rails_applications/7.1.3/bin/docker-entrypoint +8 -0
- data/spec/rails_applications/7.1.3/bin/importmap +4 -0
- data/spec/rails_applications/7.1.3/bin/rails +4 -0
- data/spec/rails_applications/7.1.3/bin/rake +4 -0
- data/spec/rails_applications/7.1.3/bin/setup +33 -0
- data/spec/rails_applications/7.1.3/config/application.rb +27 -0
- data/spec/rails_applications/7.1.3/config/boot.rb +4 -0
- data/spec/rails_applications/7.1.3/config/cable.yml +11 -0
- data/spec/rails_applications/7.1.3/config/credentials.yml.enc +1 -0
- data/spec/rails_applications/7.1.3/config/database.yml +25 -0
- data/spec/rails_applications/7.1.3/config/environment.rb +5 -0
- data/spec/rails_applications/7.1.3/config/environments/development.rb +76 -0
- data/spec/rails_applications/7.1.3/config/environments/production.rb +97 -0
- data/spec/rails_applications/7.1.3/config/environments/test.rb +64 -0
- data/spec/rails_applications/7.1.3/config/importmap.rb +7 -0
- data/spec/rails_applications/7.1.3/config/initializers/assets.rb +12 -0
- data/spec/rails_applications/7.1.3/config/initializers/content_security_policy.rb +25 -0
- data/spec/rails_applications/7.1.3/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/rails_applications/7.1.3/config/initializers/inflections.rb +16 -0
- data/spec/rails_applications/7.1.3/config/initializers/permissions_policy.rb +13 -0
- data/spec/rails_applications/7.1.3/config/locales/en.yml +31 -0
- data/spec/rails_applications/7.1.3/config/puma.rb +35 -0
- data/spec/rails_applications/7.1.3/config/routes.rb +11 -0
- data/spec/rails_applications/7.1.3/config/storage.yml +34 -0
- data/spec/rails_applications/7.1.3/config.ru +6 -0
- data/spec/rails_applications/7.1.3/db/seeds.rb +9 -0
- data/spec/{dummy/test/integration → rails_applications/7.1.3/lib/assets}/.keep +0 -0
- data/spec/{dummy/test/mailers → rails_applications/7.1.3/lib/tasks}/.keep +0 -0
- data/spec/rails_applications/7.1.3/public/404.html +67 -0
- data/spec/rails_applications/7.1.3/public/422.html +67 -0
- data/spec/rails_applications/7.1.3/public/500.html +66 -0
- data/spec/{dummy/test/models/.keep → rails_applications/7.1.3/public/apple-touch-icon-precomposed.png} +0 -0
- data/spec/{dummy/vendor/assets/javascripts/.keep → rails_applications/7.1.3/public/apple-touch-icon.png} +0 -0
- data/spec/{dummy/vendor/assets/stylesheets/.keep → rails_applications/7.1.3/public/favicon.ico} +0 -0
- data/spec/rails_applications/7.1.3/public/robots.txt +1 -0
- data/spec/rails_applications/7.1.3/storage/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/application_system_test_case.rb +5 -0
- data/spec/rails_applications/7.1.3/test/channels/application_cable/connection_test.rb +13 -0
- data/spec/rails_applications/7.1.3/test/controllers/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/controllers/home_controller_test.rb +7 -0
- data/spec/rails_applications/7.1.3/test/fixtures/files/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/helpers/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/integration/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/mailers/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/models/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/system/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/test_helper.rb +15 -0
- data/spec/rails_applications/7.1.3/vendor/.keep +0 -0
- data/spec/rails_applications/7.1.3/vendor/javascript/.keep +0 -0
- data/spec/rails_helper.rb +8 -4
- data/spec/raygun/breadcrumbs/breadcrumb_spec.rb +171 -171
- data/spec/raygun/breadcrumbs/store_spec.rb +170 -170
- 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/rails_helper.rb +6 -0
- data/test/test_helper.rb +76 -72
- data/test/unit/affected_user_test.rb +136 -136
- data/test/unit/client_test.rb +812 -812
- data/test/unit/configuration_test.rb +202 -206
- data/test/unit/error_subscriber_test.rb +43 -0
- data/test/unit/raygun_test.rb +106 -25
- data/test/unit/resque_failure_test.rb +27 -24
- data/test/unit/sidekiq_failure_test.rb +42 -32
- metadata +186 -125
- data/.travis.yml +0 -20
- data/spec/dummy/.gitignore +0 -17
- data/spec/dummy/Gemfile +0 -47
- data/spec/dummy/app/assets/config/manifest.js +0 -3
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -9
- data/spec/dummy/bin/rake +0 -9
- data/spec/dummy/bin/setup +0 -29
- data/spec/dummy/bin/spring +0 -17
- data/spec/dummy/config/application.rb +0 -26
- data/spec/dummy/config/boot.rb +0 -3
- data/spec/dummy/config/environments/development.rb +0 -41
- data/spec/dummy/config/environments/production.rb +0 -79
- data/spec/dummy/config/environments/test.rb +0 -42
- data/spec/dummy/config/initializers/assets.rb +0 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/to_time_preserves_timezone.rb +0 -10
- data/spec/dummy/config/routes.rb +0 -58
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/db/seeds.rb +0 -7
- data/spec/dummy/public/robots.txt +0 -5
- data/spec/dummy/test/test_helper.rb +0 -10
- data/spec/raygun/raygun_spec.rb +0 -47
@@ -1,206 +1,202 @@
|
|
1
|
-
require_relative "../test_helper.rb"
|
2
|
-
|
3
|
-
class ConfigurationTest < Raygun::UnitTest
|
4
|
-
|
5
|
-
class TestException < StandardError; end
|
6
|
-
class Test2Exception < StandardError; end
|
7
|
-
|
8
|
-
def setup
|
9
|
-
Raygun.setup do |config|
|
10
|
-
config.api_key = "a test api key"
|
11
|
-
config.version = 9.9
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def
|
16
|
-
Raygun.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
assert_equal
|
22
|
-
end
|
23
|
-
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
def
|
68
|
-
assert_equal(
|
69
|
-
end
|
70
|
-
|
71
|
-
def
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
Raygun.
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
assert_equal Raygun.configuration.debug
|
89
|
-
end
|
90
|
-
|
91
|
-
def
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
Raygun.configuration.
|
105
|
-
end
|
106
|
-
|
107
|
-
def
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
Raygun.
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
Raygun.
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
Raygun.
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
end
|
160
|
-
|
161
|
-
def
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
Raygun.
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
Raygun.
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
end
|
186
|
-
|
187
|
-
def
|
188
|
-
assert_equal
|
189
|
-
end
|
190
|
-
|
191
|
-
def
|
192
|
-
assert_equal false, Raygun.configuration.
|
193
|
-
end
|
194
|
-
|
195
|
-
def
|
196
|
-
assert_equal
|
197
|
-
end
|
198
|
-
|
199
|
-
def
|
200
|
-
assert_equal
|
201
|
-
end
|
202
|
-
|
203
|
-
def test_enable_reporting_default
|
204
|
-
assert_equal true, Raygun.configuration.enable_reporting
|
205
|
-
end
|
206
|
-
end
|
1
|
+
require_relative "../test_helper.rb"
|
2
|
+
|
3
|
+
class ConfigurationTest < Raygun::UnitTest
|
4
|
+
|
5
|
+
class TestException < StandardError; end
|
6
|
+
class Test2Exception < StandardError; end
|
7
|
+
|
8
|
+
def setup
|
9
|
+
Raygun.setup do |config|
|
10
|
+
config.api_key = "a test api key"
|
11
|
+
config.version = 9.9
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_setting_api_key_and_version
|
16
|
+
assert_equal 9.9, Raygun.configuration.version
|
17
|
+
assert_equal "a test api key", Raygun.configuration.api_key
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_hash_style_access
|
21
|
+
assert_equal 9.9, Raygun.configuration[:version]
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_set_js_api_key
|
25
|
+
Raygun.configuration.js_api_key = "a test js api key"
|
26
|
+
|
27
|
+
assert_equal "a test js api key", Raygun.configuration.js_api_key
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_set_js_api_version
|
31
|
+
Raygun.configuration.js_api_version = "a test js api version"
|
32
|
+
|
33
|
+
assert_equal "a test js api version", Raygun.configuration.js_api_version
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_enable_reporting
|
37
|
+
Raygun.configuration.enable_reporting = false
|
38
|
+
|
39
|
+
# should be no API call
|
40
|
+
assert_nil Raygun.track_exception(TestException.new)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_silence_reporting
|
44
|
+
Raygun.configuration.silence_reporting = true
|
45
|
+
|
46
|
+
# nothing returned as there's no HTTP call
|
47
|
+
assert_nil Raygun.track_exception(TestException.new)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_ignoring_exceptions
|
51
|
+
Raygun.configuration.ignore << TestException.to_s
|
52
|
+
|
53
|
+
assert_nil Raygun.track_exception(TestException.new)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_ignoring_multiple_exceptions
|
57
|
+
Raygun.configuration.ignore << [TestException.to_s, Test2Exception.to_s]
|
58
|
+
|
59
|
+
assert_nil Raygun.track_exception(TestException.new)
|
60
|
+
assert_nil Raygun.track_exception(Test2Exception.new)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_default_values
|
64
|
+
assert_equal({}, Raygun.configuration.custom_data)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_default_tags_set
|
68
|
+
assert_equal([], Raygun.configuration.tags)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_overriding_defaults
|
72
|
+
Raygun.default_configuration.custom_data = { robby: "robot" }
|
73
|
+
assert_equal({ robby: "robot" }, Raygun.configuration.custom_data)
|
74
|
+
|
75
|
+
Raygun.configuration.custom_data = { sally: "stegosaurus" }
|
76
|
+
assert_equal({ sally: "stegosaurus" }, Raygun.configuration.custom_data)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_debug
|
80
|
+
Raygun.setup do |config|
|
81
|
+
config.debug = true
|
82
|
+
end
|
83
|
+
|
84
|
+
assert_equal Raygun.configuration.debug, true
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_debug_default_set
|
88
|
+
assert_equal false, Raygun.configuration.debug
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_setting_filter_paramters_to_proc
|
92
|
+
Raygun.setup do |config|
|
93
|
+
config.filter_parameters do |hash|
|
94
|
+
# Don't need to do anything :)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
assert Raygun.configuration.filter_parameters.is_a?(Proc)
|
99
|
+
ensure
|
100
|
+
Raygun.configuration.filter_parameters = nil
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_filter_payload_with_whitelist_default
|
104
|
+
assert_equal(false, Raygun.configuration.filter_payload_with_whitelist)
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_setting_whitelist_payload_keys_to_proc
|
108
|
+
Raygun.setup do |config|
|
109
|
+
config.whitelist_payload_shape do |hash|
|
110
|
+
# No-op
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
assert Raygun.configuration.whitelist_payload_shape.is_a?(Proc)
|
115
|
+
ensure
|
116
|
+
Raygun.configuration.whitelist_payload_shape = nil
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_setting_custom_data_to_proc
|
120
|
+
Raygun.setup do |config|
|
121
|
+
config.custom_data do |exception, env|
|
122
|
+
# No-op
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
assert Raygun.configuration.custom_data.is_a?(Proc)
|
127
|
+
ensure
|
128
|
+
Raygun.configuration.custom_data = nil
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_setting_custom_data_to_hash
|
132
|
+
Raygun.setup do |config|
|
133
|
+
config.custom_data = {}
|
134
|
+
end
|
135
|
+
|
136
|
+
assert Raygun.configuration.custom_data.is_a?(Hash)
|
137
|
+
ensure
|
138
|
+
Raygun.configuration.custom_data = nil
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_setting_tags_to_array
|
142
|
+
Raygun.setup do |c|
|
143
|
+
c.tags = ['test']
|
144
|
+
end
|
145
|
+
|
146
|
+
assert_equal Raygun.configuration.tags, ['test']
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_setting_tags_to_proc
|
150
|
+
Raygun.setup do |c|
|
151
|
+
c.tags = ->(exception, env) {}
|
152
|
+
end
|
153
|
+
|
154
|
+
assert Raygun.configuration.tags.is_a?(Proc)
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_api_url_default
|
158
|
+
assert_equal "https://api.raygun.com/", Raygun.configuration.api_url
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_setting_breadcrumb_level
|
162
|
+
Raygun.setup do |config|
|
163
|
+
config.breadcrumb_level = :info
|
164
|
+
end
|
165
|
+
|
166
|
+
assert_equal :info, Raygun.configuration.breadcrumb_level
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_setting_breadcrumb_level_to_bad_value
|
170
|
+
logger = setup_logging
|
171
|
+
|
172
|
+
Raygun.setup do |config|
|
173
|
+
config.breadcrumb_level = :invalid
|
174
|
+
end
|
175
|
+
|
176
|
+
assert_equal :info, Raygun.configuration.breadcrumb_level
|
177
|
+
assert(
|
178
|
+
logger.get.include?("unknown breadcrumb level"),
|
179
|
+
"unknown breadcrumb level message was not logged"
|
180
|
+
)
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_breadcrumb_level_default
|
184
|
+
assert_equal :info, Raygun.configuration.breadcrumb_level
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_record_raw_data_default
|
188
|
+
assert_equal false, Raygun.configuration.record_raw_data
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_send_in_background_default
|
192
|
+
assert_equal false, Raygun.configuration.send_in_background
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_error_report_send_timeout_default
|
196
|
+
assert_equal 10, Raygun.configuration.error_report_send_timeout
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_enable_reporting_default
|
200
|
+
assert_equal true, Raygun.configuration.enable_reporting
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative "../test_helper.rb"
|
2
|
+
|
3
|
+
class ErrorSubscriberTest < Raygun::UnitTest
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
Raygun.configuration.send_in_background = false
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
def test_tracking_exception_via_subscriber
|
12
|
+
body_matcher = lambda do |body|
|
13
|
+
json = JSON.parse(body)
|
14
|
+
details = json["details"]
|
15
|
+
|
16
|
+
details["userCustomData"] &&
|
17
|
+
details["userCustomData"]["rails.error"] &&
|
18
|
+
details["userCustomData"]["rails.error"]["handled"] == true &&
|
19
|
+
details["tags"] == ["rails_error_reporter", "test_tag", "test"]
|
20
|
+
end
|
21
|
+
|
22
|
+
request_stub = stub_request(:post, 'https://api.raygun.com/entries')
|
23
|
+
.with(
|
24
|
+
body: body_matcher
|
25
|
+
)
|
26
|
+
.to_return(status: 202).times(1)
|
27
|
+
|
28
|
+
result = Raygun::ErrorSubscriber.new.report(
|
29
|
+
StandardError.new("test error"),
|
30
|
+
handled: true,
|
31
|
+
severity: "warning",
|
32
|
+
context: {
|
33
|
+
tags: ["test_tag"]
|
34
|
+
},
|
35
|
+
source: "application"
|
36
|
+
)
|
37
|
+
|
38
|
+
assert result && result.success?, "Expected success, got #{result.class}, #{result.inspect}"
|
39
|
+
|
40
|
+
assert_requested request_stub
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/test/unit/raygun_test.rb
CHANGED
@@ -1,25 +1,106 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require_relative "../test_helper.rb"
|
3
|
-
|
4
|
-
class RaygunTest < Raygun::UnitTest
|
5
|
-
def test_raygun_is_not_configured_with_no_api_key
|
6
|
-
Raygun.configuration.api_key = nil
|
7
|
-
assert !Raygun.configured?
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_should_report_logs_silence_reporting_when_debug_is_on
|
11
|
-
logger = setup_logging
|
12
|
-
Raygun.configuration.silence_reporting = true
|
13
|
-
Raygun.send(:should_report?, Exception.new)
|
14
|
-
|
15
|
-
assert logger.get.include?("silence_reporting"), "silence_reporting was not logged"
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_should_report_logs_ignored_exceptions_when_debug_is_on
|
19
|
-
logger = setup_logging
|
20
|
-
Raygun.configuration.ignore = ["Exception"]
|
21
|
-
Raygun.send(:should_report?, Exception.new)
|
22
|
-
|
23
|
-
assert logger.get =~ /skipping reporting of.*Exception.*/, "ignored exception was not logged"
|
24
|
-
end
|
25
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require_relative "../test_helper.rb"
|
3
|
+
|
4
|
+
class RaygunTest < Raygun::UnitTest
|
5
|
+
def test_raygun_is_not_configured_with_no_api_key
|
6
|
+
Raygun.configuration.api_key = nil
|
7
|
+
assert !Raygun.configured?
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_should_report_logs_silence_reporting_when_debug_is_on
|
11
|
+
logger = setup_logging
|
12
|
+
Raygun.configuration.silence_reporting = true
|
13
|
+
Raygun.send(:should_report?, Exception.new)
|
14
|
+
|
15
|
+
assert logger.get.include?("silence_reporting"), "silence_reporting was not logged"
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_should_report_logs_ignored_exceptions_when_debug_is_on
|
19
|
+
logger = setup_logging
|
20
|
+
Raygun.configuration.ignore = ["Exception"]
|
21
|
+
Raygun.send(:should_report?, Exception.new)
|
22
|
+
|
23
|
+
assert logger.get =~ /skipping reporting of.*Exception.*/, "ignored exception was not logged"
|
24
|
+
end
|
25
|
+
|
26
|
+
class BackgroundSendTest < Raygun::UnitTest
|
27
|
+
def setup
|
28
|
+
@failsafe_logger = FakeLogger.new
|
29
|
+
Raygun.setup do |c|
|
30
|
+
c.silence_reporting = false
|
31
|
+
c.send_in_background = true
|
32
|
+
c.api_url = "http://example.api"
|
33
|
+
c.api_key = "foo"
|
34
|
+
c.debug = false
|
35
|
+
c.failsafe_logger = @failsafe_logger
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_breadcrumb_context_passed
|
40
|
+
Raygun::Breadcrumbs::Store.initialize
|
41
|
+
Raygun.record_breadcrumb(message: "mmm crumbly")
|
42
|
+
assert Raygun::Breadcrumbs::Store.any?
|
43
|
+
|
44
|
+
stub_request(:post, "http://example.api/entries")
|
45
|
+
.with(body: hash_including(breadcrumbs: [ hash_including(message: "mmm crumbly") ]))
|
46
|
+
.to_return(status: 202)
|
47
|
+
|
48
|
+
Raygun.track_exception(StandardError.new)
|
49
|
+
Raygun.wait_for_futures
|
50
|
+
ensure
|
51
|
+
Raygun::Breadcrumbs::Store.clear
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_failsafe_reported_on_timeout
|
55
|
+
stub_request(:post, "http://example.api/entries").to_timeout
|
56
|
+
|
57
|
+
error = StandardError.new
|
58
|
+
|
59
|
+
Raygun.track_exception(error)
|
60
|
+
|
61
|
+
Raygun.wait_for_futures
|
62
|
+
assert_match(/Problem reporting exception to Raygun/, @failsafe_logger.get)
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
class ErrorSubscriberTest < Raygun::UnitTest
|
68
|
+
def setup
|
69
|
+
Raygun.setup do |c|
|
70
|
+
c.api_key = "test"
|
71
|
+
c.silence_reporting = false
|
72
|
+
c.debug = true
|
73
|
+
c.register_rails_error_handler = true
|
74
|
+
end
|
75
|
+
|
76
|
+
Raygun::Railtie.setup_error_subscriber
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_registers_with_rails
|
80
|
+
if ::Rails.version.to_f >= 7.0
|
81
|
+
assert Rails.error.instance_variable_get("@subscribers").any? { |s| s.is_a?(Raygun::ErrorSubscriber) }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_reports_exceptions
|
86
|
+
if ::Rails.version.to_f >= 7.0
|
87
|
+
stub_request(:post, "https://api.raygun.com/entries").to_return(status: 202)
|
88
|
+
|
89
|
+
Rails.error.handle do
|
90
|
+
raise StandardError.new("test rails handling")
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_reset_configuration
|
97
|
+
Raygun.setup do |c|
|
98
|
+
c.api_url = "http://test.api"
|
99
|
+
end
|
100
|
+
|
101
|
+
original_api_url = Raygun.configuration.api_url
|
102
|
+
Raygun.reset_configuration
|
103
|
+
assert_equal Raygun.default_configuration.api_url, Raygun.configuration.api_url
|
104
|
+
refute_equal original_api_url, Raygun.configuration.api_url
|
105
|
+
end
|
106
|
+
end
|
@@ -1,24 +1,27 @@
|
|
1
|
-
require_relative "../test_helper.rb"
|
2
|
-
|
3
|
-
# Very simple test
|
4
|
-
class ResqueFailureTest < Raygun::UnitTest
|
5
|
-
|
6
|
-
require "resque/failure/raygun"
|
7
|
-
|
8
|
-
def setup
|
9
|
-
super
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
"
|
19
|
-
"
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
1
|
+
require_relative "../test_helper.rb"
|
2
|
+
|
3
|
+
# Very simple test
|
4
|
+
class ResqueFailureTest < Raygun::UnitTest
|
5
|
+
|
6
|
+
require "resque/failure/raygun"
|
7
|
+
|
8
|
+
def setup
|
9
|
+
super
|
10
|
+
Raygun.configuration.send_in_background = false
|
11
|
+
|
12
|
+
stub_request(:post, 'https://api.raygun.com/entries').to_return(status: 202)
|
13
|
+
fake_successful_entry
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_failure_backend_appears_to_work
|
17
|
+
result = Resque::Failure::Raygun.new(
|
18
|
+
StandardError.new("Worker Problem"),
|
19
|
+
"TestWorker PID 123",
|
20
|
+
"super_important_jobs",
|
21
|
+
class: "SendCookies", args: [ "nik" ]
|
22
|
+
).save
|
23
|
+
|
24
|
+
assert result && result.success?, "Expected success, got #{result.inspect}"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|