airbrake 4.3.8 → 5.0.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.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/lib/airbrake/capistrano/tasks.rb +64 -0
  3. data/lib/airbrake/delayed_job/plugin.rb +48 -0
  4. data/lib/airbrake/rack/middleware.rb +45 -0
  5. data/lib/airbrake/rack/notice_builder.rb +80 -0
  6. data/lib/airbrake/rack/user.rb +51 -0
  7. data/lib/airbrake/rails/action_controller.rb +35 -0
  8. data/lib/airbrake/rails/active_job.rb +23 -0
  9. data/lib/airbrake/rails/active_record.rb +40 -0
  10. data/lib/airbrake/rails/railtie.rb +61 -0
  11. data/lib/airbrake/rake/task_ext.rb +61 -0
  12. data/lib/airbrake/rake/tasks.rb +93 -0
  13. data/lib/airbrake/resque/failure.rb +19 -0
  14. data/lib/airbrake/sidekiq/error_handler.rb +35 -0
  15. data/lib/airbrake/version.rb +4 -1
  16. data/lib/airbrake.rb +16 -185
  17. data/lib/generators/airbrake_generator.rb +25 -0
  18. data/lib/generators/airbrake_initializer.rb.erb +55 -0
  19. data/spec/airbrake_spec.rb +0 -0
  20. data/spec/apps/rack/dummy_app.rb +17 -0
  21. data/spec/apps/rails/dummy_app.rb +150 -0
  22. data/spec/apps/rails/dummy_task.rake +20 -0
  23. data/spec/apps/rails/logs/32.log +13358 -0
  24. data/spec/apps/rails/logs/40.log +6854 -0
  25. data/spec/apps/rails/logs/41.log +3170 -0
  26. data/spec/apps/rails/logs/42.log +23919 -0
  27. data/spec/apps/rails/logs/50.log +10976 -0
  28. data/spec/apps/sinatra/dummy_app.rb +12 -0
  29. data/spec/integration/rack/rack_spec.rb +17 -0
  30. data/spec/integration/rails/rails_spec.rb +135 -0
  31. data/spec/integration/rails/rake_spec.rb +160 -0
  32. data/spec/integration/shared_examples/rack_examples.rb +106 -0
  33. data/spec/integration/sinatra/sinatra_spec.rb +15 -0
  34. data/spec/spec_helper.rb +127 -0
  35. data/spec/unit/rack/middleware_spec.rb +80 -0
  36. data/spec/unit/rack/notice_builder_spec.rb +35 -0
  37. data/spec/unit/rack/user_spec.rb +78 -0
  38. data/spec/unit/rake/tasks_spec.rb +40 -0
  39. data/spec/unit/sidekiq/error_handler_spec.rb +29 -0
  40. metadata +108 -323
  41. data/CHANGELOG +0 -1716
  42. data/Gemfile +0 -3
  43. data/Guardfile +0 -6
  44. data/INSTALL +0 -20
  45. data/LICENSE +0 -61
  46. data/README.md +0 -148
  47. data/README_FOR_HEROKU_ADDON.md +0 -102
  48. data/Rakefile +0 -179
  49. data/TESTED_AGAINST +0 -7
  50. data/airbrake.gemspec +0 -41
  51. data/bin/airbrake +0 -12
  52. data/features/metal.feature +0 -34
  53. data/features/rack.feature +0 -60
  54. data/features/rails.feature +0 -324
  55. data/features/rake.feature +0 -33
  56. data/features/sinatra.feature +0 -126
  57. data/features/step_definitions/file_steps.rb +0 -14
  58. data/features/step_definitions/rack_steps.rb +0 -27
  59. data/features/step_definitions/rails_application_steps.rb +0 -267
  60. data/features/step_definitions/rake_steps.rb +0 -22
  61. data/features/support/airbrake_shim.rb.template +0 -11
  62. data/features/support/aruba.rb +0 -5
  63. data/features/support/env.rb +0 -39
  64. data/features/support/matchers.rb +0 -35
  65. data/features/support/rails.rb +0 -156
  66. data/features/support/rake/Rakefile +0 -77
  67. data/features/user_informer.feature +0 -57
  68. data/generators/airbrake/airbrake_generator.rb +0 -94
  69. data/generators/airbrake/lib/insert_commands.rb +0 -34
  70. data/generators/airbrake/lib/rake_commands.rb +0 -24
  71. data/generators/airbrake/templates/airbrake_tasks.rake +0 -25
  72. data/generators/airbrake/templates/capistrano_hook.rb +0 -6
  73. data/generators/airbrake/templates/initializer.rb +0 -4
  74. data/install.rb +0 -1
  75. data/lib/airbrake/backtrace.rb +0 -103
  76. data/lib/airbrake/capistrano.rb +0 -103
  77. data/lib/airbrake/capistrano3.rb +0 -3
  78. data/lib/airbrake/cli/client.rb +0 -76
  79. data/lib/airbrake/cli/options.rb +0 -45
  80. data/lib/airbrake/cli/printer.rb +0 -33
  81. data/lib/airbrake/cli/project.rb +0 -17
  82. data/lib/airbrake/cli/project_factory.rb +0 -33
  83. data/lib/airbrake/cli/runner.rb +0 -49
  84. data/lib/airbrake/cli/validator.rb +0 -8
  85. data/lib/airbrake/configuration.rb +0 -366
  86. data/lib/airbrake/jobs/send_job.rb +0 -7
  87. data/lib/airbrake/notice.rb +0 -411
  88. data/lib/airbrake/rack.rb +0 -64
  89. data/lib/airbrake/rails/action_controller_catcher.rb +0 -32
  90. data/lib/airbrake/rails/controller_methods.rb +0 -146
  91. data/lib/airbrake/rails/error_lookup.rb +0 -35
  92. data/lib/airbrake/rails/middleware.rb +0 -63
  93. data/lib/airbrake/rails.rb +0 -45
  94. data/lib/airbrake/rails3_tasks.rb +0 -126
  95. data/lib/airbrake/railtie.rb +0 -46
  96. data/lib/airbrake/rake_handler.rb +0 -75
  97. data/lib/airbrake/response.rb +0 -29
  98. data/lib/airbrake/sender.rb +0 -213
  99. data/lib/airbrake/shared_tasks.rb +0 -59
  100. data/lib/airbrake/sidekiq.rb +0 -8
  101. data/lib/airbrake/sinatra.rb +0 -40
  102. data/lib/airbrake/tasks/airbrake.cap +0 -28
  103. data/lib/airbrake/tasks.rb +0 -81
  104. data/lib/airbrake/user_informer.rb +0 -36
  105. data/lib/airbrake/utils/params_cleaner.rb +0 -141
  106. data/lib/airbrake/utils/rack_filters.rb +0 -45
  107. data/lib/airbrake_tasks.rb +0 -62
  108. data/lib/rails/generators/airbrake/airbrake_generator.rb +0 -155
  109. data/lib/templates/rescue.erb +0 -91
  110. data/rails/init.rb +0 -1
  111. data/resources/README.md +0 -34
  112. data/resources/airbrake_2_4.xsd +0 -89
  113. data/resources/airbrake_3_0.json +0 -52
  114. data/resources/ca-bundle.crt +0 -3376
  115. data/script/integration_test.rb +0 -35
  116. data/test/airbrake_tasks_test.rb +0 -161
  117. data/test/backtrace_test.rb +0 -215
  118. data/test/capistrano_test.rb +0 -44
  119. data/test/configuration_test.rb +0 -303
  120. data/test/controller_methods_test.rb +0 -230
  121. data/test/helper.rb +0 -233
  122. data/test/integration/catcher_test.rb +0 -371
  123. data/test/integration.rb +0 -13
  124. data/test/logger_test.rb +0 -79
  125. data/test/notice_test.rb +0 -494
  126. data/test/notifier_test.rb +0 -288
  127. data/test/params_cleaner_test.rb +0 -204
  128. data/test/rack_test.rb +0 -62
  129. data/test/rails_initializer_test.rb +0 -36
  130. data/test/recursion_test.rb +0 -10
  131. data/test/response_test.rb +0 -18
  132. data/test/sender_test.rb +0 -335
  133. data/test/support/response_shim.xml +0 -4
  134. data/test/user_informer_test.rb +0 -29
data/test/notice_test.rb DELETED
@@ -1,494 +0,0 @@
1
- require File.expand_path '../helper', __FILE__
2
-
3
- class NoticeTest < Test::Unit::TestCase
4
-
5
- include DefinesConstants
6
-
7
- def configure
8
- Airbrake::Configuration.new.tap do |config|
9
- config.api_key = 'abc123def456'
10
- end
11
- end
12
-
13
- def build_notice(args = {})
14
- configuration = args.delete(:configuration) || configure
15
- Airbrake::Notice.new(configuration.merge(args))
16
- end
17
-
18
- def stub_request(attrs = {})
19
- stub('request', { :parameters => { 'one' => 'two' },
20
- :protocol => 'http',
21
- :host => 'some.host',
22
- :request_uri => '/some/uri',
23
- :session => { :to_hash => { 'a' => 'b' } },
24
- :env => { 'three' => 'four' } }.update(attrs))
25
- end
26
-
27
- def assert_accepts_exception_attribute(attribute, args = {}, &block)
28
- exception = build_exception
29
- block ||= lambda { exception.send(attribute) }
30
- value = block.call(exception)
31
-
32
- notice_from_exception = build_notice(args.merge(:exception => exception))
33
-
34
- assert_equal notice_from_exception.send(attribute),
35
- value,
36
- "#{attribute} was not correctly set from an exception"
37
-
38
- notice_from_hash = build_notice(args.merge(attribute => value))
39
- assert_equal notice_from_hash.send(attribute),
40
- value,
41
- "#{attribute} was not correctly set from a hash"
42
- end
43
-
44
- def assert_valid_notice_document(document)
45
- xsd_path = File.expand_path(File.join(File.dirname(__FILE__),"..", "resources", "airbrake_2_4.xsd"))
46
- schema = Nokogiri::XML::Schema.new(IO.read(xsd_path))
47
- errors = schema.validate(document)
48
- assert errors.empty?, errors.collect{|e| e.message }.join
49
- end
50
-
51
- def assert_valid_json(notice)
52
- json_schema = File.expand_path(File.join(File.dirname(__FILE__),"..", "resources", "airbrake_3_0.json"))
53
- errors = JSON::Validator.fully_validate(json_schema, notice)
54
- assert errors.empty?, errors.join
55
- end
56
-
57
- def build_backtrace_array
58
- ["app/models/user.rb:13:in `magic'",
59
- "app/controllers/users_controller.rb:8:in `index'"]
60
- end
61
-
62
- def hostname
63
- `hostname`.chomp
64
- end
65
-
66
- def user
67
- Struct.new(:email,:id,:name).
68
- new("darth@vader.com",1,"Anakin Skywalker")
69
- end
70
-
71
- should "call the cleaner on initialization" do
72
- cleaner = stub
73
- cleaner.expects(:clean).returns(stub(:parameters => {}, :cgi_data => {}, :session_data => {}))
74
- Airbrake::Notice.new(:cleaner => cleaner)
75
- end
76
-
77
- should "set the api key" do
78
- api_key = 'key'
79
- notice = build_notice(:api_key => api_key)
80
- assert_equal api_key, notice.api_key
81
- end
82
-
83
- should "accept a project root" do
84
- project_root = '/path/to/project'
85
- notice = build_notice(:project_root => project_root)
86
- assert_equal project_root, notice.project_root
87
- end
88
-
89
- should "accept a component" do
90
- assert_equal 'users_controller', build_notice(:component => 'users_controller').controller
91
- end
92
-
93
- should "alias the component as controller" do
94
- assert_equal 'users_controller', build_notice(:controller => 'users_controller').component
95
- assert_equal 'users_controller', build_notice(:component => 'users_controller').controller
96
- end
97
-
98
- should "accept a action" do
99
- assert_equal 'index', build_notice(:action => 'index').action
100
- end
101
-
102
- should "accept a url" do
103
- url = 'http://some.host/uri'
104
- notice = build_notice(:url => url)
105
- assert_equal url, notice.url
106
- end
107
-
108
- should "set the host name" do
109
- notice = build_notice
110
- assert_equal hostname, notice.hostname
111
- end
112
-
113
- should "accept a backtrace from an exception or hash" do
114
- array = ["user.rb:34:in `crazy'"]
115
- exception = build_exception
116
- exception.set_backtrace array
117
- backtrace = Airbrake::Backtrace.parse(array)
118
- notice_from_exception = build_notice(:exception => exception)
119
-
120
-
121
- assert_equal backtrace,
122
- notice_from_exception.backtrace,
123
- "backtrace was not correctly set from an exception"
124
-
125
- notice_from_hash = build_notice(:backtrace => array)
126
- assert_equal backtrace,
127
- notice_from_hash.backtrace,
128
- "backtrace was not correctly set from a hash"
129
- end
130
-
131
- should "accept user" do
132
- assert_equal user.id, build_notice(:user => user).user.id
133
- assert_equal user.email, build_notice(:user => user).user.email
134
- assert_equal user.name, build_notice(:user => user).user.name
135
- end
136
-
137
- should "pass its backtrace filters for parsing" do
138
- backtrace_array = ['my/file/backtrace:3']
139
- exception = build_exception
140
- exception.set_backtrace(backtrace_array)
141
- Airbrake::Backtrace.expects(:parse).with(backtrace_array, {:filters => 'foo'})
142
-
143
- Airbrake::Notice.new({:exception => exception, :backtrace_filters => 'foo'})
144
- end
145
-
146
- should "set the error class from an exception or hash" do
147
- assert_accepts_exception_attribute :error_class do |exception|
148
- exception.class.name
149
- end
150
- end
151
-
152
- should "set the error message from an exception or hash" do
153
- assert_accepts_exception_attribute :error_message do |exception|
154
- "#{exception.class.name}: #{exception.message}"
155
- end
156
- end
157
-
158
- should "accept parameters from a request or hash" do
159
- parameters = { 'one' => 'two' }
160
- notice_from_hash = build_notice(:parameters => parameters)
161
- assert_equal notice_from_hash.parameters, parameters
162
- end
163
-
164
- should "accept session data from a session[:data] hash" do
165
- data = { 'one' => 'two' }
166
- notice = build_notice(:session => { :data => data })
167
- assert_equal data, notice.session_data
168
- end
169
-
170
- should "accept session data from a session_data hash" do
171
- data = { 'one' => 'two' }
172
- notice = build_notice(:session_data => data)
173
- assert_equal data, notice.session_data
174
- end
175
-
176
- should "accept an environment name" do
177
- assert_equal 'development', build_notice(:environment_name => 'development').environment_name
178
- end
179
-
180
- should "accept CGI data from a hash" do
181
- data = { 'string' => 'value' }
182
- notice = build_notice(:cgi_data => data)
183
- assert_equal data, notice.cgi_data, "should take CGI data from a hash"
184
- end
185
-
186
- should "not crash without CGI data" do
187
- assert_nothing_raised do
188
- build_notice
189
- end
190
- end
191
-
192
- should "accept any object that responds to :to_hash as CGI data" do
193
- hashlike_obj = Object.new
194
- hashlike_obj.instance_eval do
195
- def to_hash
196
- {:i => 'am a hash'}
197
- end
198
- end
199
- assert hashlike_obj.respond_to?(:to_hash)
200
-
201
- notice = build_notice(:cgi_data => hashlike_obj)
202
- assert_equal({:i => 'am a hash'}, notice.cgi_data, "should take CGI data from any hash-like object")
203
- end
204
-
205
- should "accept notifier information" do
206
- params = { :notifier_name => 'a name for a notifier',
207
- :notifier_version => '1.0.5',
208
- :notifier_url => 'http://notifiers.r.us/download' }
209
- notice = build_notice(params)
210
- assert_equal params[:notifier_name], notice.notifier_name
211
- assert_equal params[:notifier_version], notice.notifier_version
212
- assert_equal params[:notifier_url], notice.notifier_url
213
- end
214
-
215
- should "set sensible defaults without an exception" do
216
- backtrace = Airbrake::Backtrace.parse(build_backtrace_array)
217
- notice = build_notice(:backtrace => build_backtrace_array)
218
-
219
- assert_equal 'Notification', notice.error_message
220
- assert_array_starts_with backtrace.lines, notice.backtrace.lines
221
- assert_equal({}, notice.parameters)
222
- assert_equal({}, notice.session_data)
223
- end
224
-
225
- should "use the caller as the backtrace for an exception without a backtrace" do
226
- filters = Airbrake::Configuration.new.backtrace_filters
227
- backtrace = Airbrake::Backtrace.parse(caller, :filters => filters)
228
- notice = build_notice(:exception => StandardError.new('error'), :backtrace => nil)
229
-
230
- assert_array_starts_with backtrace.lines, notice.backtrace.lines
231
- end
232
-
233
- context "a Notice turned into JSON" do
234
- setup do
235
- @exception = build_exception
236
-
237
- @notice = build_notice({
238
- :notifier_name => 'a name',
239
- :notifier_version => '1.2.3',
240
- :notifier_url => 'http://some.url/path',
241
- :exception => @exception,
242
- :controller => "controller",
243
- :action => "action",
244
- :url => "http://url.com",
245
- :parameters => { "paramskey" => "paramsvalue",
246
- "nestparentkey" => { "nestkey" => "nestvalue" } },
247
- :session_data => { "sessionkey" => "sessionvalue" },
248
- :cgi_data => { "cgikey" => "cgivalue" },
249
- :project_root => "RAILS_ROOT",
250
- :environment_name => "RAILS_ENV"
251
- })
252
-
253
- @json = @notice.to_json
254
- end
255
-
256
- should "validate against the JSON schema" do
257
- assert_valid_json @json
258
- end
259
- end
260
-
261
- context "a Notice turned into XML" do
262
- setup do
263
- Airbrake.configure do |config|
264
- config.api_key = "1234567890"
265
- end
266
-
267
- @exception = build_exception
268
-
269
- @notice = build_notice({
270
- :notifier_name => 'a name',
271
- :notifier_version => '1.2.3',
272
- :notifier_url => 'http://some.url/path',
273
- :exception => @exception,
274
- :controller => "controller",
275
- :action => "action",
276
- :url => "http://url.com",
277
- :parameters => { "paramskey" => "paramsvalue",
278
- "nestparentkey" => { "nestkey" => "nestvalue" } },
279
- :session_data => { "sessionkey" => "sessionvalue" },
280
- :cgi_data => { "cgikey" => "cgivalue" },
281
- :project_root => "RAILS_ROOT",
282
- :environment_name => "RAILS_ENV"
283
- })
284
-
285
- @xml = @notice.to_xml
286
-
287
- @document = Nokogiri::XML::Document.parse(@xml)
288
- end
289
-
290
- should "validate against the XML schema" do
291
- assert_valid_notice_document @document
292
- end
293
-
294
-
295
- should "serialize a Notice to XML when sent #to_xml" do
296
- assert_valid_node(@document, "//api-key", @notice.api_key)
297
-
298
- assert_valid_node(@document, "//notifier/name", @notice.notifier_name)
299
- assert_valid_node(@document, "//notifier/version", @notice.notifier_version)
300
- assert_valid_node(@document, "//notifier/url", @notice.notifier_url)
301
-
302
- assert_valid_node(@document, "//error/class", @notice.error_class)
303
- assert_valid_node(@document, "//error/message", @notice.error_message)
304
-
305
- assert_valid_node(@document, "//error/backtrace/line/@number", @notice.backtrace.lines.first.number)
306
- assert_valid_node(@document, "//error/backtrace/line/@file", @notice.backtrace.lines.first.file)
307
- assert_valid_node(@document, "//error/backtrace/line/@method", @notice.backtrace.lines.first.method_name)
308
-
309
- assert_valid_node(@document, "//request/url", @notice.url)
310
- assert_valid_node(@document, "//request/component", @notice.controller)
311
- assert_valid_node(@document, "//request/action", @notice.action)
312
-
313
- assert_valid_node(@document, "//request/params/var/@key", "paramskey")
314
- assert_valid_node(@document, "//request/params/var", "paramsvalue")
315
- assert_valid_node(@document, "//request/params/var/@key", "nestparentkey")
316
- assert_valid_node(@document, "//request/params/var/var/@key", "nestkey")
317
- assert_valid_node(@document, "//request/params/var/var", "nestvalue")
318
- assert_valid_node(@document, "//request/session/var/@key", "sessionkey")
319
- assert_valid_node(@document, "//request/session/var", "sessionvalue")
320
- assert_valid_node(@document, "//request/cgi-data/var/@key", "cgikey")
321
- assert_valid_node(@document, "//request/cgi-data/var", "cgivalue")
322
-
323
- assert_valid_node(@document, "//server-environment/project-root", "RAILS_ROOT")
324
- assert_valid_node(@document, "//server-environment/environment-name", "RAILS_ENV")
325
- assert_valid_node(@document, "//server-environment/hostname", hostname)
326
- end
327
- end
328
-
329
- should "not send empty request data" do
330
- notice = build_notice
331
- assert_nil notice.url
332
- assert_nil notice.controller
333
- assert_nil notice.action
334
-
335
- xml = notice.to_xml
336
- document = Nokogiri::XML.parse(xml)
337
- assert_nil document.at('//request/url')
338
- assert_nil document.at('//request/component')
339
- assert_nil document.at('//request/action')
340
-
341
- assert_valid_notice_document document
342
- end
343
-
344
- %w(url controller action).each do |var|
345
- should "send a request if #{var} is present" do
346
- notice = build_notice(var.to_sym => 'value')
347
- xml = notice.to_xml
348
- document = Nokogiri::XML.parse(xml)
349
- assert_not_nil document.at('//request')
350
- end
351
- end
352
-
353
- %w(parameters cgi_data session_data).each do |var|
354
- should "send a request if #{var} is present" do
355
- notice = build_notice(var.to_sym => { 'key' => 'value' })
356
- xml = notice.to_xml
357
- document = Nokogiri::XML.parse(xml)
358
- assert_not_nil document.at('//request')
359
- end
360
- end
361
-
362
- should "not ignore an exception not matching ignore filters" do
363
- notice = build_notice(:error_class => 'ArgumentError',
364
- :ignore => ['Argument'],
365
- :ignore_by_filters => [lambda { |n| false }])
366
- assert !notice.ignore?
367
- end
368
-
369
- should "ignore an wrapped exception matching ignore filters" do
370
- notice = build_notice(error_class: "NotIgnored",
371
- exception_classes: ["Ignored", "NotIgnored"],
372
- ignore: ["Ignored"])
373
- assert notice.ignore?
374
- end
375
-
376
- should "ignore an exception with a matching error class" do
377
- notice = build_notice(:error_class => 'ArgumentError',
378
- :ignore => [ArgumentError])
379
- assert notice.ignore?
380
- end
381
-
382
- should "ignore an exception with a matching error class name" do
383
- notice = build_notice(:error_class => 'ArgumentError',
384
- :ignore => ['ArgumentError'])
385
- assert notice.ignore?
386
- end
387
-
388
- should "ignore an exception with a matching filter" do
389
- filter = lambda {|notice| notice.error_class == 'ArgumentError' }
390
- notice = build_notice(:error_class => 'ArgumentError',
391
- :ignore_by_filters => [filter])
392
- assert notice.ignore?
393
- end
394
-
395
- should "not raise without an ignore list" do
396
- notice = build_notice(:ignore => nil, :ignore_by_filters => nil)
397
- assert_nothing_raised do
398
- notice.ignore?
399
- end
400
- end
401
-
402
- ignored_error_classes = Airbrake::Configuration::IGNORE_DEFAULT
403
-
404
- ignored_error_classes.each do |ignored_error_class|
405
- should "ignore #{ignored_error_class} error by default" do
406
- notice = build_notice(:error_class => ignored_error_class)
407
- assert notice.ignore?
408
- end
409
- end
410
-
411
- should "act like a hash" do
412
- notice = build_notice(:error_message => 'some message')
413
- assert_equal notice.error_message, notice[:error_message]
414
- end
415
-
416
- should "return params on notice[:request][:params]" do
417
- params = { 'one' => 'two' }
418
- notice = build_notice(:parameters => params)
419
- assert_equal params, notice[:request][:params]
420
- end
421
-
422
- should "ensure #to_hash is called on objects that support it" do
423
- assert_nothing_raised do
424
- build_notice(:session => { :object => stub(:to_hash => {}) })
425
- end
426
- end
427
-
428
- should "ensure #to_ary is called on objects that support it" do
429
- assert_nothing_raised do
430
- build_notice(:session => { :object => stub(:to_ary => []) })
431
- end
432
- end
433
-
434
- should "extract data from a rack environment hash" do
435
- url = "https://subdomain.happylane.com:100/test/file.rb?var=value&var2=value2"
436
- parameters = { 'var' => 'value', 'var2' => 'value2' }
437
- env = Rack::MockRequest.env_for(url)
438
-
439
- notice = build_notice(:rack_env => env)
440
-
441
- assert_equal url, notice.url
442
- assert_equal parameters, notice.parameters
443
- assert_equal 'GET', notice.cgi_data['REQUEST_METHOD']
444
- end
445
-
446
- should "show a nice warning when rack environment exceeds rack keyspace" do
447
- # simulate exception for too big query
448
- Rack::Request.any_instance.expects(:params).raises(RangeError.new("exceeded available parameter key space"))
449
-
450
- url = "https://subdomain.happylane.com:100/test/file.rb?var=x"
451
- env = Rack::MockRequest.env_for(url)
452
-
453
- notice = build_notice(:rack_env => env)
454
-
455
- assert_equal url, notice.url
456
- assert_equal({:message => "failed to call params on Rack::Request -- exceeded available parameter key space"}, notice.parameters)
457
- assert_equal 'GET', notice.cgi_data['REQUEST_METHOD']
458
- end
459
-
460
- should "extract data from a rack environment hash with action_dispatch info" do
461
- params = { 'controller' => 'users', 'action' => 'index', 'id' => '7' }
462
- env = Rack::MockRequest.env_for('/', { 'action_dispatch.request.parameters' => params })
463
-
464
- notice = build_notice(:rack_env => env)
465
-
466
- assert_equal params, notice.parameters
467
- assert_equal params['controller'], notice.component
468
- assert_equal params['action'], notice.action
469
- end
470
-
471
- should "extract session data from a rack environment" do
472
- session_data = { 'something' => 'some value' }
473
- env = Rack::MockRequest.env_for('/', 'rack.session' => session_data)
474
-
475
- notice = build_notice(:rack_env => env)
476
-
477
- assert_equal session_data, notice.session_data
478
- end
479
-
480
- should "prefer passed session data to rack session data" do
481
- session_data = { 'something' => 'some value' }
482
- env = Rack::MockRequest.env_for('/')
483
-
484
- notice = build_notice(:rack_env => env, :session_data => session_data)
485
-
486
- assert_equal session_data, notice.session_data
487
- end
488
-
489
- should "prefer passed error_message to exception message" do
490
- exception = build_exception
491
- notice = build_notice(:exception => exception,:error_message => "Random ponies")
492
- assert_equal "BacktracedException: Random ponies", notice.error_message
493
- end
494
- end