crashbreak 0.9.9 → 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4df45d34d6e9036c52b70b7c7719925cd7204228
4
- data.tar.gz: fd14f19299eb5dab7082000818db713f714d1e76
3
+ metadata.gz: 049fadb7ad06d34a0cee543f5c51cb12f88b91eb
4
+ data.tar.gz: b5b854e144727e47300921c6f88a7bd5947cfe31
5
5
  SHA512:
6
- metadata.gz: 3b59aa2de3910274e2c670487634f4f0dbed9ce987b3f3a55fda5c698c741b86a81dc508e31066eeefb7ef0349ca9db3c31eaef115dce9351e3a542827f1cdfa
7
- data.tar.gz: 5d7fdc4a29c2e1407815148d094b76ef86885cf7900acaedecc4f0e4966d86c7304ef8fd2ce5516b2fd5be610c05ac9dff4bc1a44afb6b643c8e301ef1d050e3
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
- error_id = exceptions_repository.create serialize_exception
5
- GithubIntegrationService.new(error_id).push_test if Crashbreak.configure.github_repo_name.present?
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
@@ -3,7 +3,7 @@ module Crashbreak
3
3
  BASE_URL = 'http://crashbreak.herokuapp.com/api'
4
4
 
5
5
  def create(error_report_hash)
6
- JSON.parse(post_request(error_report_hash).body)['id']
6
+ JSON.parse(post_request(error_report_hash).body)
7
7
  end
8
8
 
9
9
  def resolve(error_id)
@@ -1,7 +1,8 @@
1
1
  module Crashbreak
2
2
  class GithubIntegrationService
3
- def initialize(error_id)
4
- @error_id = 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 ||= client.ref(repo_name, 'heads/master').object.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
@@ -1,3 +1,3 @@
1
1
  module Crashbreak
2
- VERSION = '0.9.9'
2
+ VERSION = '0.9.10'
3
3
  end
@@ -41,37 +41,37 @@ describe Crashbreak::ExceptionNotifier do
41
41
  end
42
42
  end
43
43
 
44
- context 'github integration' do
45
- let(:error_id) { 1 }
44
+ context 'with additional serializers' do
45
+ let(:expected_hash) { exception_basic_hash.merge(serializer_hash) }
46
46
 
47
- it 'passes error id from request to github integration service' do
48
- Crashbreak.configure.github_repo_name = 'user/repo'
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
- allow_any_instance_of(Crashbreak::ExceptionsRepository).to receive(:create).and_return(error_id)
51
- expect_any_instance_of(Crashbreak::GithubIntegrationService).to receive(:initialize).with(error_id)
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
- context 'with additional serializers' do
59
- let(:expected_hash) { exception_basic_hash.merge(serializer_hash) }
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
- let(:serializer) { double(:serializer) }
67
+ it 'passes error hash from request to github integration service' do
68
+ Crashbreak.configure.github_repo_name = 'user/repo'
66
69
 
67
- before(:each) do
68
- allow(serializer).to receive(:serialize).and_return(serializer_hash)
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
- it 'sends formatted error' do
73
- expect_any_instance_of(Crashbreak::ExceptionsRepository).to receive(:create).with(expected_hash)
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 error_id }
2
+ subject { described_class.new error_hash }
3
3
 
4
- let(:error_id) { 1 }
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(:post, github_refs_url).with(body: { ref: 'refs/heads/crashbreak-error-1', sha: git_sha}.to_json)
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crashbreak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9
4
+ version: 0.9.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Janeczek