vx-service_connector 0.2.19 → 0.2.20

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: 2e8860acc2f0b4675438cf042873da0c64299235
4
- data.tar.gz: 8f782d34ded7d0742b70be0c24d7862e02e9fc9f
3
+ metadata.gz: be3cec4a635997e6ec7fbfe8ad9c030b8206f7a4
4
+ data.tar.gz: b8674641becff7494dcc92798e91acb0c1a21937
5
5
  SHA512:
6
- metadata.gz: aeced5f68311012be6e0c93c12c8bb79d0e21defc9e8841037dc181565c8bb4172537a4e988edf1623b6332042195e0763b582e1258851ea530dca54cb0236cf
7
- data.tar.gz: d4910f9c35fc9af5a901174d16b625ad7d38d729610cc1e4324d337dbb530be737450ac1b1b19213f7d9e7c12f43ec4d9358d4161389f2825d41f1bcfc965263
6
+ metadata.gz: aafa13cf97ffd8e1f17c109d514104c7c4f9fce3cba43b3c55c4d1694e6c25770831b991c2b3908ed072c264e3b89ec157a84bd6af2071fe8351461049e960c6
7
+ data.tar.gz: 29888d03c6b2a95b3b16d08932b429b1546a0498e3b41dfcc75afdab20934c3a49c929e7d3455d160fc84f189c9de8371cb15cd51e19c2431ce4715949143283
@@ -6,7 +6,7 @@ module Vx
6
6
 
7
7
  def build
8
8
  ServiceConnector::Model::Payload.new(
9
- !!ignore?,
9
+ !valid?,
10
10
  !!pull_request?,
11
11
  pull_request_number,
12
12
  branch,
@@ -21,6 +21,14 @@ module Vx
21
21
 
22
22
  private
23
23
 
24
+ def valid?
25
+ if ignore?
26
+ false
27
+ else
28
+ message && author && author_email || false
29
+ end
30
+ end
31
+
24
32
  def message
25
33
  commit_for_payload["title"]
26
34
  end
@@ -120,7 +128,7 @@ module Vx
120
128
  session.get("/projects/#{repo.id}")
121
129
  rescue RequestError => e
122
130
  $stderr.puts "ERROR: #{e.inspect}"
123
- nil
131
+ {}
124
132
  end
125
133
  end
126
134
 
@@ -149,7 +157,7 @@ module Vx
149
157
  def commit_for_payload
150
158
  @commit_for_payload ||=
151
159
  begin
152
- if not ignore?
160
+ if !ignore? && sha
153
161
  session.get(commit_uri(repo.id, sha))
154
162
  else
155
163
  {}
@@ -29,7 +29,7 @@ module Vx
29
29
  def to_hash ; to_h end
30
30
 
31
31
  def ignore?
32
- skip || message.to_s =~ /#{PAYLOAD_IGNORE_RE}/
32
+ !!(skip || message.to_s =~ /#{PAYLOAD_IGNORE_RE}/)
33
33
  end
34
34
 
35
35
  class << self
@@ -1,5 +1,5 @@
1
1
  module Vx
2
2
  module ServiceConnector
3
- VERSION = "0.2.19"
3
+ VERSION = "0.2.20"
4
4
  end
5
5
  end
@@ -0,0 +1,20 @@
1
+ {
2
+ "object_kind": "merge_request",
3
+ "object_attributes": {
4
+ "id": 575,
5
+ "target_branch": "master",
6
+ "source_branch": "vs-reject-code-request",
7
+ "source_project_id": 1,
8
+ "author_id": 12,
9
+ "assignee_id": 3,
10
+ "title": "Reject Code Request",
11
+ "created_at": "2014-11-06T23:29:31.000Z",
12
+ "updated_at": "2014-11-13T09:40:15.563Z",
13
+ "milestone_id": null,
14
+ "state": "opened",
15
+ "merge_status": "unchecked",
16
+ "target_project_id": 1,
17
+ "iid": 575,
18
+ "description": ""
19
+ }
20
+ }
@@ -61,4 +61,23 @@ describe Vx::ServiceConnector::GitlabV6::Payload do
61
61
 
62
62
  its(:ignore?) { should be_true }
63
63
  end
64
+
65
+ context "when identity is not authorized on push request" do
66
+ before do
67
+ mock_project_not_found 1
68
+ mock_get_commit_not_found 1, "decc3915e29d7ae1786bb981b2ea3702afae592a"
69
+ end
70
+ its(:ignore?) { should be_true }
71
+ end
72
+
73
+ context "when identity is not authorized on merge request" do
74
+ let(:content) { read_json_fixture("gitlab_v6/payload/merge_request") }
75
+ before do
76
+ mock_project_not_found 1
77
+ mock_branch_not_found 1, "some-branch-name"
78
+ mock_get_commit_not_found 1, "a7c31647c6449c3d98c4027d97e00b3048ac3bbf"
79
+ end
80
+ its(:ignore?) { should be_true }
81
+ end
82
+
64
83
  end
@@ -31,4 +31,31 @@ module GitlabV6WebMocks
31
31
  def mock_project(pid)
32
32
  mock_get "projects/#{pid}", 'project'
33
33
  end
34
+
35
+ def mock_project_not_found(pid)
36
+ stub_request(:get, "http://example.com/api/v3/projects/#{pid}").
37
+ with(:headers => {'Accept'=>'application/json', 'PRIVATE-TOKEN' => "token"}).
38
+ to_return(
39
+ :status => 404,
40
+ :body => {:status=>"404", :error=>"Not Found"}.to_json,
41
+ :headers => {'Content-Type' => 'application/json'})
42
+ end
43
+
44
+ def mock_get_commit_not_found(pid, sha)
45
+ stub_request(:get, "http://example.com/api/v3/projects/#{pid}/repository/commits/#{sha}").
46
+ with(:headers => {'Accept'=>'application/json', 'PRIVATE-TOKEN' => "token"}).
47
+ to_return(
48
+ :status => 404,
49
+ :body => {:status=>"404", :error=>"Not Found"}.to_json,
50
+ :headers => {'Content-Type' => 'application/json'})
51
+ end
52
+
53
+ def mock_branch_not_found(pid, name)
54
+ stub_request(:get, "http://example.com/api/v3/projects/#{pid}/repository/branches/#{name}").
55
+ with(:headers => {'Accept'=>'application/json', 'PRIVATE-TOKEN' => "token"}).
56
+ to_return(
57
+ :status => 404,
58
+ :body => {:status=>"404", :error=>"Not Found"}.to_json,
59
+ :headers => {'Content-Type' => 'application/json'})
60
+ end
34
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vx-service_connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.19
4
+ version: 0.2.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Galinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-12 00:00:00.000000000 Z
11
+ date: 2014-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -206,6 +206,7 @@ files:
206
206
  - spec/fixtures/gitlab_v6/commits.json
207
207
  - spec/fixtures/gitlab_v6/deploy_keys.json
208
208
  - spec/fixtures/gitlab_v6/hooks.json
209
+ - spec/fixtures/gitlab_v6/payload/bug_1.json
209
210
  - spec/fixtures/gitlab_v6/payload/closed_merge_request.json
210
211
  - spec/fixtures/gitlab_v6/payload/merge_request.json
211
212
  - spec/fixtures/gitlab_v6/payload/merged_merge_request.json
@@ -296,6 +297,7 @@ test_files:
296
297
  - spec/fixtures/gitlab_v6/commits.json
297
298
  - spec/fixtures/gitlab_v6/deploy_keys.json
298
299
  - spec/fixtures/gitlab_v6/hooks.json
300
+ - spec/fixtures/gitlab_v6/payload/bug_1.json
299
301
  - spec/fixtures/gitlab_v6/payload/closed_merge_request.json
300
302
  - spec/fixtures/gitlab_v6/payload/merge_request.json
301
303
  - spec/fixtures/gitlab_v6/payload/merged_merge_request.json