crashbreak 1.0.14 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/crashbreak/version.rb +1 -1
- data/lib/dumpers/request_dumper.rb +13 -11
- data/lib/generators/crashbreak/templates/minitest_test.rb +1 -1
- data/lib/generators/crashbreak/templates/rspec_test.rb +1 -1
- data/lib/restorers/request_restorer.rb +8 -6
- data/lib/restorers/state_restorer.rb +29 -27
- data/spec/dumpers/request_dumper_spec.rb +1 -1
- data/spec/features/sending_error_report_spec.rb +2 -2
- data/spec/lib/exception_notifier_spec.rb +2 -2
- data/spec/restorers/state_restorer_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74e84b99a284bce15c89b8a7c540651735e57e54
|
4
|
+
data.tar.gz: 7e89937326e1d084d7963e457d7dcfad3d533374
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f377660ef75f2a7a1bd13e591b2b8b482c7a820aff2eb4afff78ba5c80a91d12e28237f362e4093b88e5ba356ce2cf923b3ef5c98d6ef5f035f73a91c80dfc08
|
7
|
+
data.tar.gz: 6746333573e47834aa54d3a44d9d41e0af407b18370b0e45a4f68f33ab299170b657b06e25d693340e89f7e8e5f06b48dd14854cd6f53ac4bec1a7d22635a45f
|
data/lib/crashbreak/version.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module Crashbreak
|
2
|
+
class RequestDumper < Crashbreak::BasicFormatter
|
3
|
+
def dump
|
4
|
+
sanitized_request_hash
|
5
|
+
end
|
5
6
|
|
6
|
-
|
7
|
+
private
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def sanitized_request_hash
|
10
|
+
{}.tap do |sanitized_request_hash|
|
11
|
+
request_hash.each{|key, value| sanitized_request_hash[key] = value.to_s }
|
12
|
+
end
|
11
13
|
end
|
12
|
-
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
def request_hash
|
16
|
+
request.env
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
@@ -2,7 +2,7 @@ require_relative 'test/test_helper.rb'
|
|
2
2
|
|
3
3
|
class ErrorRequestTest < ActionDispatch::IntegrationTest
|
4
4
|
def setup
|
5
|
-
@restorers_data = StateRestorer.new('<%= error_id %>').restore
|
5
|
+
@restorers_data = Crashbreak::StateRestorer.new('<%= error_id %>').restore
|
6
6
|
@request_parser = Crashbreak::RequestParser.new @restorers_data[:request]
|
7
7
|
end
|
8
8
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
describe 'error id: <%= error_id %>', type: :request do
|
2
2
|
|
3
|
-
let(:restorers_data) { StateRestorer.new('<%= error_id %>').restore }
|
3
|
+
let(:restorers_data) { Crashbreak::StateRestorer.new('<%= error_id %>').restore }
|
4
4
|
let(:request_parser) { Crashbreak::RequestParser.new restorers_data[:request] }
|
5
5
|
|
6
6
|
it 'sends request' do
|
@@ -1,9 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module Crashbreak
|
2
|
+
class RequestRestorer
|
3
|
+
def initialize(request_data)
|
4
|
+
@request_data = request_data
|
5
|
+
end
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
def restore
|
8
|
+
@request_data
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
@@ -1,37 +1,39 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module Crashbreak
|
2
|
+
class StateRestorer
|
3
|
+
def initialize(error_id)
|
4
|
+
@error_id = error_id
|
5
|
+
end
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
def restore
|
8
|
+
{}.tap do |restorers_hash|
|
9
|
+
restorers.each do |restorer|
|
10
|
+
restorers_hash[key_name(restorer)] = restorer.new(dumper_data(restorer)).restore
|
11
|
+
end
|
11
12
|
end
|
12
13
|
end
|
13
|
-
end
|
14
14
|
|
15
|
-
|
15
|
+
private
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
def dumpers_data
|
18
|
+
@dumpers_data ||= Crashbreak::DumpersDataRepository.new(@error_id).dumpers_data
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
def restorers
|
22
|
+
dumpers_data.keys.map {|dumper_name| restorer_class_by_dumper_name(dumper_name)}
|
23
|
+
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
def restorer_class_by_dumper_name(dumper_name)
|
26
|
+
dumper_name.gsub('Dumper', 'Restorer').constantize
|
27
|
+
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
def dumper_data(restorer)
|
30
|
+
dumper_name = restorer.to_s.gsub('Restorer', 'Dumper')
|
31
|
+
dumpers_data[dumper_name].merge('error_id' => @error_id)
|
32
|
+
end
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
def key_name(restorer)
|
35
|
+
restorer.to_s.gsub('Restorer', '').underscore.to_sym
|
36
|
+
end
|
36
37
|
end
|
37
|
-
|
38
|
+
|
39
|
+
end
|
@@ -12,7 +12,7 @@ describe 'Sending error report to server' do
|
|
12
12
|
before(:each) do
|
13
13
|
Crashbreak.configure.api_key = project_token
|
14
14
|
Crashbreak.configure.error_serializers = [summary_formatter, Crashbreak::EnvironmentVariablesFormatter.new, TestErrorFormatter.new]
|
15
|
-
Crashbreak.configure.dumpers = [RequestDumper.new]
|
15
|
+
Crashbreak.configure.dumpers = [Crashbreak::RequestDumper.new]
|
16
16
|
|
17
17
|
allow(crashing_app).to receive(:call).and_raise(example_error)
|
18
18
|
allow(example_error).to receive(:backtrace).and_return(%w(example backtrace))
|
@@ -39,7 +39,7 @@ describe 'Sending error report to server' do
|
|
39
39
|
with(body: dumpers_data.to_json).to_return(status: 200)
|
40
40
|
end
|
41
41
|
|
42
|
-
let(:dumpers_data) { Hash[error_report: { dumpers_data: { 'RequestDumper' => example_request.env } }] }
|
42
|
+
let(:dumpers_data) { Hash[error_report: { dumpers_data: { 'Crashbreak::RequestDumper' => example_request.env } }] }
|
43
43
|
|
44
44
|
it 'sends error report on exception' do
|
45
45
|
expect{ catching_middleware.call(env) }.to raise_error(TestError)
|
@@ -36,11 +36,11 @@ describe Crashbreak::ExceptionNotifier do
|
|
36
36
|
|
37
37
|
context 'with dumpers' do
|
38
38
|
let(:dumpers_hash) do
|
39
|
-
{ dumpers_data: { 'RequestDumper' => { request: 'example_request_data' } } }
|
39
|
+
{ dumpers_data: { 'Crashbreak::RequestDumper' => { request: 'example_request_data' } } }
|
40
40
|
end
|
41
41
|
|
42
42
|
before(:each) do
|
43
|
-
allow_any_instance_of(described_class).to receive(:dumpers).and_return([RequestDumper.new])
|
43
|
+
allow_any_instance_of(described_class).to receive(:dumpers).and_return([Crashbreak::RequestDumper.new])
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'sends dump data' do
|