crashbreak 0.9.9 → 0.9.10
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.
- checksums.yaml +4 -4
- data/lib/crashbreak/exception_notifier.rb +2 -2
- data/lib/crashbreak/exceptions_repository.rb +1 -1
- data/lib/crashbreak/github_integration_service.rb +10 -3
- data/lib/crashbreak/version.rb +1 -1
- data/spec/lib/exception_notifier_spec.rb +21 -21
- data/spec/lib/exceptions_repository_spec.rb +3 -2
- data/spec/lib/github_integration_service_spec.rb +6 -3
- 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: 049fadb7ad06d34a0cee543f5c51cb12f88b91eb
|
4
|
+
data.tar.gz: b5b854e144727e47300921c6f88a7bd5947cfe31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf6074ee2b2b7db7ff8d29efa35a1329f77109ddfb2e8a9c985a56bef54753b24c081260624d2eed240a3a8f17ce92d242de252ade5047ae5e2c53c3cf98e63d
|
7
|
+
data.tar.gz: dd5dd8039dac2068fee5e20dd31ec4504668e8f8e99f63ea30f7c50cf52a56ad3cdbf64ea6e136b564d50ea6bb9f8850e336c8f663c785ce27e7cc6f345d048c
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Crashbreak
|
2
2
|
class ExceptionNotifier
|
3
3
|
def notify
|
4
|
-
|
5
|
-
GithubIntegrationService.new(
|
4
|
+
response = exceptions_repository.create serialize_exception
|
5
|
+
GithubIntegrationService.new(response).push_test if Crashbreak.configure.github_repo_name.present?
|
6
6
|
end
|
7
7
|
|
8
8
|
private
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Crashbreak
|
2
2
|
class GithubIntegrationService
|
3
|
-
def initialize(
|
4
|
-
@error_id =
|
3
|
+
def initialize(error_hash)
|
4
|
+
@error_id = error_hash['id']
|
5
|
+
@error_deploy_revision = error_hash['deploy_revision']
|
5
6
|
end
|
6
7
|
|
7
8
|
def push_test
|
@@ -21,7 +22,13 @@ module Crashbreak
|
|
21
22
|
private
|
22
23
|
|
23
24
|
def branch_sha
|
24
|
-
@branch_sha ||=
|
25
|
+
@branch_sha ||= begin
|
26
|
+
if @error_deploy_revision
|
27
|
+
client.commit(repo_name, @error_deploy_revision).sha
|
28
|
+
else
|
29
|
+
client.ref(repo_name, 'heads/master').object.sha
|
30
|
+
end
|
31
|
+
end
|
25
32
|
end
|
26
33
|
|
27
34
|
def test_file_sha
|
data/lib/crashbreak/version.rb
CHANGED
@@ -41,37 +41,37 @@ describe Crashbreak::ExceptionNotifier do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
context '
|
45
|
-
let(:
|
44
|
+
context 'with additional serializers' do
|
45
|
+
let(:expected_hash) { exception_basic_hash.merge(serializer_hash) }
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
let(:serializer_hash) do
|
48
|
+
{ additional_key: :example, additional_data: { looks_good: :yes } }
|
49
|
+
end
|
50
|
+
|
51
|
+
let(:serializer) { double(:serializer) }
|
49
52
|
|
50
|
-
|
51
|
-
|
53
|
+
before(:each) do
|
54
|
+
allow(serializer).to receive(:serialize).and_return(serializer_hash)
|
55
|
+
allow_any_instance_of(Crashbreak::Configurator).to receive(:error_serializers).and_return([serializer])
|
56
|
+
end
|
52
57
|
|
58
|
+
it 'sends formatted error' do
|
59
|
+
expect_any_instance_of(Crashbreak::ExceptionsRepository).to receive(:create).with(expected_hash)
|
53
60
|
subject.notify
|
54
61
|
end
|
55
62
|
end
|
56
|
-
end
|
57
63
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
let(:serializer_hash) do
|
62
|
-
{ additional_key: :example, additional_data: { looks_good: :yes } }
|
63
|
-
end
|
64
|
+
context 'github integration' do
|
65
|
+
let(:error_hash) { Hash[id: 1, deploy_revision: 'test'] }
|
64
66
|
|
65
|
-
|
67
|
+
it 'passes error hash from request to github integration service' do
|
68
|
+
Crashbreak.configure.github_repo_name = 'user/repo'
|
66
69
|
|
67
|
-
|
68
|
-
|
69
|
-
allow_any_instance_of(Crashbreak::Configurator).to receive(:error_serializers).and_return([serializer])
|
70
|
-
end
|
70
|
+
allow_any_instance_of(Crashbreak::ExceptionsRepository).to receive(:create).and_return(error_hash)
|
71
|
+
expect_any_instance_of(Crashbreak::GithubIntegrationService).to receive(:initialize).with(error_hash)
|
71
72
|
|
72
|
-
|
73
|
-
|
74
|
-
subject.notify
|
73
|
+
subject.notify
|
74
|
+
end
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -3,6 +3,7 @@ describe Crashbreak::ExceptionsRepository do
|
|
3
3
|
|
4
4
|
let(:project_token) { 'example_project_token' }
|
5
5
|
let(:exception_id) { 1 }
|
6
|
+
let(:current_deploy_revision) { 'current_deploy_revision' }
|
6
7
|
|
7
8
|
before(:each) do
|
8
9
|
Crashbreak.configure.api_key = project_token
|
@@ -17,7 +18,7 @@ describe Crashbreak::ExceptionsRepository do
|
|
17
18
|
|
18
19
|
let!(:create_exception_request) do
|
19
20
|
stub_request(:post, "#{described_class::BASE_URL}/projects/#{project_token}/errors").
|
20
|
-
with(body: error_report_hash.to_json).to_return(status: 200, body: { id: exception_id }.to_json)
|
21
|
+
with(body: error_report_hash.to_json).to_return(status: 200, body: { id: exception_id, deploy_revision: current_deploy_revision }.to_json)
|
21
22
|
end
|
22
23
|
|
23
24
|
let!(:resolve_exception_request) do
|
@@ -26,7 +27,7 @@ describe Crashbreak::ExceptionsRepository do
|
|
26
27
|
end
|
27
28
|
|
28
29
|
it 'sends request to create exception report' do
|
29
|
-
expect(subject.create error_report_hash).to eq exception_id
|
30
|
+
expect(subject.create error_report_hash).to eq('id' => exception_id, 'deploy_revision' => current_deploy_revision)
|
30
31
|
expect(create_exception_request).to have_been_made
|
31
32
|
end
|
32
33
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
describe Crashbreak::GithubIntegrationService do
|
2
|
-
subject { described_class.new
|
2
|
+
subject { described_class.new error_hash }
|
3
3
|
|
4
|
-
let(:
|
4
|
+
let(:error_hash) { Hash['id' => 1, 'deploy_revision' => 'example_deploy_revision'] }
|
5
5
|
let(:branch_name) { 'refs/heads/crashbreak-error-1' }
|
6
6
|
let(:git_sha) { 'example_sha' }
|
7
7
|
let(:file_content) { 'example_file_content' }
|
@@ -11,6 +11,7 @@ describe Crashbreak::GithubIntegrationService do
|
|
11
11
|
let(:github_create_content_url) { 'https://api.github.com/repos/user/repo/contents' }
|
12
12
|
let(:github_test_file_url) { 'https://api.github.com/repos/user/repo/contents/spec/crashbreak_error_spec.rb' }
|
13
13
|
let(:github_pull_requests_url) { 'https://api.github.com/repos/user/repo/pulls' }
|
14
|
+
let(:github_deploy_commit_url) { 'https://api.github.com/repos/user/repo/commits/example_deploy_revision' }
|
14
15
|
|
15
16
|
before(:each) do
|
16
17
|
Crashbreak.configure.github_spec_file_path = 'spec/crashbreak_error_spec.rb'
|
@@ -19,7 +20,9 @@ describe Crashbreak::GithubIntegrationService do
|
|
19
20
|
it 'pushes test to github' do
|
20
21
|
stub_request(:get, github_master_ref_url).to_return(body: DeepStruct.wrap(object: { sha: git_sha } ))
|
21
22
|
|
22
|
-
stub_request(:
|
23
|
+
stub_request(:get, github_deploy_commit_url).to_return(body: DeepStruct.wrap(sha: 'example_deploy_revision'))
|
24
|
+
|
25
|
+
stub_request(:post, github_refs_url).with(body: { ref: 'refs/heads/crashbreak-error-1', sha: 'example_deploy_revision'}.to_json)
|
23
26
|
|
24
27
|
stub_request(:put, "#{github_create_content_url}/#{Crashbreak.configure.github_spec_file_path}").
|
25
28
|
with(body: { branch: branch_name, content: Base64.strict_encode64(file_content), message: 'Add test file for error 1' }.to_json)
|