vx-service_connector 0.0.5 → 0.0.6
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/vx/service_connector/base.rb +3 -4
- data/lib/vx/service_connector/github/payload.rb +73 -38
- data/lib/vx/service_connector/github.rb +6 -6
- data/lib/vx/service_connector/{gitlab_v4 → gitlab_v5}/files.rb +1 -1
- data/lib/vx/service_connector/{gitlab_v4 → gitlab_v5}/hooks.rb +1 -1
- data/lib/vx/service_connector/{gitlab_v4 → gitlab_v5}/notices.rb +1 -1
- data/lib/vx/service_connector/gitlab_v5/payload.rb +112 -0
- data/lib/vx/service_connector/{gitlab_v4 → gitlab_v5}/repos.rb +1 -1
- data/lib/vx/service_connector/{gitlab_v4 → gitlab_v5}/session.rb +1 -1
- data/lib/vx/service_connector/gitlab_v5.rb +30 -2
- data/lib/vx/service_connector/model.rb +12 -20
- data/lib/vx/service_connector/version.rb +1 -1
- data/lib/vx/service_connector.rb +0 -19
- data/spec/fixtures/github/payload/foreign_pull_request.json +810 -1
- data/spec/fixtures/github/payload/pull_request.json +0 -1
- data/spec/fixtures/github/payload/push_tag.json +0 -1
- data/spec/fixtures/{gitlab_v4 → gitlab_v5}/commits.json +0 -0
- data/spec/fixtures/{gitlab_v4 → gitlab_v5}/hooks.json +0 -0
- data/spec/fixtures/gitlab_v5/payload/push.json +32 -0
- data/spec/fixtures/{gitlab_v4 → gitlab_v5}/projects.json +0 -0
- data/spec/fixtures/{gitlab_v4 → gitlab_v5}/user_keys.json +0 -0
- data/spec/lib/github_payload_spec.rb +43 -94
- data/spec/lib/github_spec.rb +0 -23
- data/spec/lib/gitlab_v5_payload_spec.rb +33 -0
- data/spec/lib/gitlab_v5_spec.rb +74 -0
- data/spec/lib/model_spec.rb +3 -28
- data/spec/lib/service_connector_spec.rb +0 -35
- data/spec/support/github_web_mocks.rb +2 -2
- data/spec/support/gitlab_v5_web_mocks.rb +41 -2
- metadata +20 -32
- data/lib/vx/service_connector/github/commits.rb +0 -33
- data/lib/vx/service_connector/gitlab_v4/commits.rb +0 -35
- data/lib/vx/service_connector/gitlab_v4/deploy_keys.rb +0 -32
- data/lib/vx/service_connector/gitlab_v4/payload.rb +0 -126
- data/lib/vx/service_connector/gitlab_v4.rb +0 -49
- data/spec/fixtures/gitlab_v4/payload/merge_request1_unchecked.json +0 -47
- data/spec/fixtures/gitlab_v4/payload/merge_request2_can_be_merge.json +0 -47
- data/spec/fixtures/gitlab_v4/payload/push.json +0 -106
- data/spec/lib/gitlab_v4_payload_spec.rb +0 -101
- data/spec/lib/gitlab_v4_spec.rb +0 -141
- data/spec/support/gitlab_v4_web_mocks.rb +0 -73
@@ -1,33 +0,0 @@
|
|
1
|
-
module Vx
|
2
|
-
module ServiceConnector
|
3
|
-
class Github
|
4
|
-
Commits = Struct.new(:session, :repo) do
|
5
|
-
|
6
|
-
def get(sha)
|
7
|
-
begin
|
8
|
-
commit = session.commit repo.full_name, sha
|
9
|
-
commit_to_model commit
|
10
|
-
rescue ::Octokit::NotFound => e
|
11
|
-
$stderr.puts "ERROR: #{e.inspect}"
|
12
|
-
nil
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def commit_to_model(commit)
|
19
|
-
url = commit.rels[:html]
|
20
|
-
|
21
|
-
Model::Commit.new(
|
22
|
-
commit.sha,
|
23
|
-
commit.commit.message,
|
24
|
-
commit.commit.author.name,
|
25
|
-
commit.commit.author.email,
|
26
|
-
url && url.href
|
27
|
-
)
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'base64'
|
2
|
-
|
3
|
-
module Vx
|
4
|
-
module ServiceConnector
|
5
|
-
class GitlabV4
|
6
|
-
Commits = Struct.new(:session, :repo) do
|
7
|
-
|
8
|
-
def get(sha)
|
9
|
-
begin
|
10
|
-
all_commits = session.get "/projects/#{repo.id}/repository/commits", ref_name: sha
|
11
|
-
commits_to_model all_commits
|
12
|
-
rescue RequestError => e
|
13
|
-
$stderr.puts "ERROR: #{e.inspect}"
|
14
|
-
nil
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def commits_to_model(commits)
|
21
|
-
if commit = commits.first
|
22
|
-
Model::Commit.new(
|
23
|
-
commit.id,
|
24
|
-
commit.title,
|
25
|
-
commit.author_name,
|
26
|
-
commit.author_email,
|
27
|
-
nil
|
28
|
-
)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module Vx
|
2
|
-
module ServiceConnector
|
3
|
-
class GitlabV4
|
4
|
-
DeployKeys = Struct.new(:session, :repo) do
|
5
|
-
|
6
|
-
def all
|
7
|
-
session.get "/user/keys"
|
8
|
-
end
|
9
|
-
|
10
|
-
def create(key_name, public_key)
|
11
|
-
key_name = compute_key_name(key_name)
|
12
|
-
session.post "/user/keys", title: key_name, key: public_key
|
13
|
-
end
|
14
|
-
|
15
|
-
def destroy(key_name)
|
16
|
-
key_name = compute_key_name(key_name)
|
17
|
-
all.select do |key|
|
18
|
-
key.title == key_name
|
19
|
-
end.map do |key|
|
20
|
-
session.delete "/user/keys/#{key.id}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
def compute_key_name(orig_name)
|
26
|
-
"#{orig_name} for #{repo.full_name}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
@@ -1,126 +0,0 @@
|
|
1
|
-
module Vx
|
2
|
-
module ServiceConnector
|
3
|
-
class GitlabV4
|
4
|
-
class Payload
|
5
|
-
|
6
|
-
def initialize(params)
|
7
|
-
@params = params || {}
|
8
|
-
end
|
9
|
-
|
10
|
-
def pull_request?
|
11
|
-
self["object_kind"] == 'merge_request'
|
12
|
-
end
|
13
|
-
|
14
|
-
def tag?
|
15
|
-
false
|
16
|
-
end
|
17
|
-
|
18
|
-
def pull_request_number
|
19
|
-
if pull_request?
|
20
|
-
pull_request["id"]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def head
|
25
|
-
if pull_request?
|
26
|
-
cid = (pull_request["st_commits"] || []).first
|
27
|
-
cid && cid["id"]
|
28
|
-
else
|
29
|
-
self["after"]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def base
|
34
|
-
if pull_request?
|
35
|
-
cid = (pull_request["st_commits"] || []).first
|
36
|
-
cid && cid["parent_ids"] && cid["parent_ids"].first
|
37
|
-
else
|
38
|
-
self["before"]
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def branch
|
43
|
-
if pull_request?
|
44
|
-
pull_request["source_branch"]
|
45
|
-
else
|
46
|
-
self["ref"].to_s.split("refs/heads/").last
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def branch_label
|
51
|
-
branch
|
52
|
-
end
|
53
|
-
|
54
|
-
def url
|
55
|
-
self["commits"] && self["commits"].first && self["commits"].first["url"]
|
56
|
-
end
|
57
|
-
|
58
|
-
def pull_request_head_repo_id
|
59
|
-
if pull_request?
|
60
|
-
pull_request["target_project_id"]
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def pull_request_base_repo_id
|
65
|
-
if pull_request?
|
66
|
-
pull_request["source_project_id"]
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def closed_pull_request?
|
71
|
-
false
|
72
|
-
end
|
73
|
-
|
74
|
-
def foreign_pull_request?
|
75
|
-
pull_request_base_repo_id != pull_request_head_repo_id
|
76
|
-
end
|
77
|
-
|
78
|
-
def pull_request_status
|
79
|
-
if pull_request?
|
80
|
-
pull_request["merge_status"]
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def ignore_pull_request?
|
85
|
-
if pull_request?
|
86
|
-
pull_request_status != 'unchecked'
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def ignore?
|
91
|
-
head == '0000000000000000000000000000000000000000' ||
|
92
|
-
ignore_pull_request?
|
93
|
-
end
|
94
|
-
|
95
|
-
def to_model
|
96
|
-
ServiceConnector::Model::Payload.new(
|
97
|
-
!!pull_request?,
|
98
|
-
pull_request_number,
|
99
|
-
head,
|
100
|
-
base,
|
101
|
-
branch,
|
102
|
-
branch_label,
|
103
|
-
url,
|
104
|
-
!!ignore?
|
105
|
-
)
|
106
|
-
end
|
107
|
-
|
108
|
-
private
|
109
|
-
|
110
|
-
def pull_request
|
111
|
-
self["object_attributes"] || {}
|
112
|
-
end
|
113
|
-
|
114
|
-
def key?(name)
|
115
|
-
@params.key? name
|
116
|
-
end
|
117
|
-
|
118
|
-
def [](val)
|
119
|
-
@params[val]
|
120
|
-
end
|
121
|
-
|
122
|
-
end
|
123
|
-
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'gitlab'
|
2
|
-
|
3
|
-
module Vx
|
4
|
-
module ServiceConnector
|
5
|
-
GitlabV4 = Struct.new(:endpoint, :private_token) do
|
6
|
-
|
7
|
-
include ServiceConnector::Base
|
8
|
-
|
9
|
-
def repos
|
10
|
-
@repos ||= GitlabV4::Repos.new(session).to_a
|
11
|
-
end
|
12
|
-
|
13
|
-
def organizations
|
14
|
-
[]
|
15
|
-
end
|
16
|
-
|
17
|
-
def hooks(repo)
|
18
|
-
GitlabV4::Hooks.new(session, repo)
|
19
|
-
end
|
20
|
-
|
21
|
-
def deploy_keys(repo)
|
22
|
-
GitlabV4::DeployKeys.new(session, repo)
|
23
|
-
end
|
24
|
-
|
25
|
-
def notices(repo)
|
26
|
-
GitlabV4::Notices.new(session, repo)
|
27
|
-
end
|
28
|
-
|
29
|
-
def files(repo)
|
30
|
-
GitlabV4::Files.new(session, repo)
|
31
|
-
end
|
32
|
-
|
33
|
-
def commits(repo)
|
34
|
-
GitlabV4::Commits.new(session, repo)
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def create_session
|
40
|
-
GitlabV4::Session.new(endpoint, private_token)
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
Dir[File.expand_path("../gitlab_v4/*.rb", __FILE__)].each do |f|
|
48
|
-
require f
|
49
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"object_kind": "merge_request",
|
3
|
-
"object_attributes": {
|
4
|
-
"id": 1,
|
5
|
-
"target_branch": "master",
|
6
|
-
"source_branch": "one",
|
7
|
-
"source_project_id": 1,
|
8
|
-
"author_id": 1,
|
9
|
-
"assignee_id": null,
|
10
|
-
"title": "One",
|
11
|
-
"created_at": "2014-01-29T16:14:38.113Z",
|
12
|
-
"updated_at": "2014-01-29T16:14:45.845Z",
|
13
|
-
"st_commits": [
|
14
|
-
{
|
15
|
-
"id": "d0862adb2c46aecb3db4cb4a50867599e4015cf9",
|
16
|
-
"message": "one",
|
17
|
-
"parent_ids": [
|
18
|
-
"f1f92a4ef47a4257973282718449154938c3684d"
|
19
|
-
],
|
20
|
-
"authored_date": "2014-01-29T16:13:20+00:00",
|
21
|
-
"author_name": "Dmitry Galinsky",
|
22
|
-
"author_email": "dima.exe@gmail.com",
|
23
|
-
"committed_date": "2014-01-29T16:13:20+00:00",
|
24
|
-
"committer_name": "Dmitry Galinsky",
|
25
|
-
"committer_email": "dima.exe@gmail.com"
|
26
|
-
}
|
27
|
-
],
|
28
|
-
"st_diffs": [
|
29
|
-
{
|
30
|
-
"diff": "--- a/README\n+++ b/README\n@@ -1 +1,2 @@\n 1\n+2",
|
31
|
-
"new_path": "README",
|
32
|
-
"old_path": "README",
|
33
|
-
"a_mode": null,
|
34
|
-
"b_mode": "100644",
|
35
|
-
"new_file": false,
|
36
|
-
"renamed_file": false,
|
37
|
-
"deleted_file": false
|
38
|
-
}
|
39
|
-
],
|
40
|
-
"milestone_id": null,
|
41
|
-
"state": "opened",
|
42
|
-
"merge_status": "unchecked",
|
43
|
-
"target_project_id": 1,
|
44
|
-
"iid": 1,
|
45
|
-
"description": "."
|
46
|
-
}
|
47
|
-
}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"object_kind": "merge_request",
|
3
|
-
"object_attributes": {
|
4
|
-
"id": 1,
|
5
|
-
"target_branch": "master",
|
6
|
-
"source_branch": "one",
|
7
|
-
"source_project_id": 1,
|
8
|
-
"author_id": 1,
|
9
|
-
"assignee_id": null,
|
10
|
-
"title": "One",
|
11
|
-
"created_at": "2014-01-29T16:14:38.000Z",
|
12
|
-
"updated_at": "2014-01-29T16:14:49.246Z",
|
13
|
-
"st_commits": [
|
14
|
-
{
|
15
|
-
"id": "d0862adb2c46aecb3db4cb4a50867599e4015cf9",
|
16
|
-
"message": "one",
|
17
|
-
"parent_ids": [
|
18
|
-
"f1f92a4ef47a4257973282718449154938c3684d"
|
19
|
-
],
|
20
|
-
"authored_date": "2014-01-29T16:13:20+00:00",
|
21
|
-
"author_name": "Dmitry Galinsky",
|
22
|
-
"author_email": "dima.exe@gmail.com",
|
23
|
-
"committed_date": "2014-01-29T16:13:20+00:00",
|
24
|
-
"committer_name": "Dmitry Galinsky",
|
25
|
-
"committer_email": "dima.exe@gmail.com"
|
26
|
-
}
|
27
|
-
],
|
28
|
-
"st_diffs": [
|
29
|
-
{
|
30
|
-
"diff": "--- a/README\n+++ b/README\n@@ -1 +1,2 @@\n 1\n+2",
|
31
|
-
"new_path": "README",
|
32
|
-
"old_path": "README",
|
33
|
-
"a_mode": null,
|
34
|
-
"b_mode": "100644",
|
35
|
-
"new_file": false,
|
36
|
-
"renamed_file": false,
|
37
|
-
"deleted_file": false
|
38
|
-
}
|
39
|
-
],
|
40
|
-
"milestone_id": null,
|
41
|
-
"state": "opened",
|
42
|
-
"merge_status": "can_be_merged",
|
43
|
-
"target_project_id": 1,
|
44
|
-
"iid": 1,
|
45
|
-
"description": "."
|
46
|
-
}
|
47
|
-
}
|
@@ -1,106 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"before": "e9f2a24318cf0a08dc2d7b987b9d8484e8c89406",
|
3
|
-
"after": "a1dfcca6369dcbd19607c4cc0f932194d8bdf57d",
|
4
|
-
"ref": "refs/heads/master",
|
5
|
-
"user_id": 228,
|
6
|
-
"user_name": "User Name",
|
7
|
-
"repository": {
|
8
|
-
"name": "SQERP",
|
9
|
-
"url": "git@gitlab.example.com:sqerp.git",
|
10
|
-
"description": null,
|
11
|
-
"homepage": "https://gitlab.example.com/sqerp"
|
12
|
-
},
|
13
|
-
"commits": [
|
14
|
-
{
|
15
|
-
"id": "4b65377d80364713293df276d7756ff6253eedcd",
|
16
|
-
"message": "Merge branch '93537_hours_units_in_details' of gitlab.example.com:sqerp",
|
17
|
-
"timestamp": "2014-01-21T08:51:56+04:00",
|
18
|
-
"url": "https://gitlab.example.com/sqerp/commit/4b65377d80364713293df276d7756ff6253eedcd",
|
19
|
-
"author": {
|
20
|
-
"name": "User Name",
|
21
|
-
"email": "me@example.com"
|
22
|
-
}
|
23
|
-
},
|
24
|
-
{
|
25
|
-
"id": "17574ef138f188e5b51a1f036448c92296b674e7",
|
26
|
-
"message": "[97241] activities_controller specs",
|
27
|
-
"timestamp": "2014-01-21T18:26:16+04:00",
|
28
|
-
"url": "https://gitlab.example.com/sqerp/commit/17574ef138f188e5b51a1f036448c92296b674e7",
|
29
|
-
"author": {
|
30
|
-
"name": "User Name",
|
31
|
-
"email": "me@example.com"
|
32
|
-
}
|
33
|
-
},
|
34
|
-
{
|
35
|
-
"id": "ca71c5938c9c796cddf2d5a32c2689669998bb0d",
|
36
|
-
"message": "fixes #84078 Custom roles.",
|
37
|
-
"timestamp": "2014-01-22T11:20:10+04:00",
|
38
|
-
"url": "https://gitlab.example.com/sqerp/commit/ca71c5938c9c796cddf2d5a32c2689669998bb0d",
|
39
|
-
"author": {
|
40
|
-
"name": "Maxim Dorofienko",
|
41
|
-
"email": "dorofienko@gmail.com"
|
42
|
-
}
|
43
|
-
},
|
44
|
-
{
|
45
|
-
"id": "f27d4dca4e7094fbb2206cd61ecbf933d77f0897",
|
46
|
-
"message": "[96071] merge ad_campaing's table",
|
47
|
-
"timestamp": "2014-01-22T12:20:55+04:00",
|
48
|
-
"url": "https://gitlab.example.com/sqerp/commit/f27d4dca4e7094fbb2206cd61ecbf933d77f0897",
|
49
|
-
"author": {
|
50
|
-
"name": "Evgeny Li",
|
51
|
-
"email": "exaspark@gmail.com"
|
52
|
-
}
|
53
|
-
},
|
54
|
-
{
|
55
|
-
"id": "432ead814f28ec1701584b7ffe130eeb8ecd3e1f",
|
56
|
-
"message": "csv exporter fix",
|
57
|
-
"timestamp": "2014-01-23T13:25:38+04:00",
|
58
|
-
"url": "https://gitlab.example.com/sqerp/commit/432ead814f28ec1701584b7ffe130eeb8ecd3e1f",
|
59
|
-
"author": {
|
60
|
-
"name": "Dmitry Koprov",
|
61
|
-
"email": "dmitry.koprov@gmail.com"
|
62
|
-
}
|
63
|
-
},
|
64
|
-
{
|
65
|
-
"id": "780c2e4a26ebf10691d157a64e3d7259f369d48f",
|
66
|
-
"message": "Merge branch '97241_controller_tests' of gitlab.example.com:sqerp",
|
67
|
-
"timestamp": "2014-01-23T14:58:27+04:00",
|
68
|
-
"url": "https://gitlab.example.com/sqerp/commit/780c2e4a26ebf10691d157a64e3d7259f369d48f",
|
69
|
-
"author": {
|
70
|
-
"name": "User Name",
|
71
|
-
"email": "me@example.com"
|
72
|
-
}
|
73
|
-
},
|
74
|
-
{
|
75
|
-
"id": "e63d231b1c3e6286bea9ffbceebd6c12d87e3dc7",
|
76
|
-
"message": "[98386] env fix",
|
77
|
-
"timestamp": "2014-01-28T11:52:48+04:00",
|
78
|
-
"url": "https://gitlab.example.com/sqerp/commit/e63d231b1c3e6286bea9ffbceebd6c12d87e3dc7",
|
79
|
-
"author": {
|
80
|
-
"name": "User Name",
|
81
|
-
"email": "me@example.com"
|
82
|
-
}
|
83
|
-
},
|
84
|
-
{
|
85
|
-
"id": "09d62be9db7e476b01c9773b5e06e5fc6a550d3c",
|
86
|
-
"message": "Merge branch '98386_fix' of gitlab.example.com:sqerp",
|
87
|
-
"timestamp": "2014-01-28T11:54:49+04:00",
|
88
|
-
"url": "https://gitlab.example.com/sqerp/commit/09d62be9db7e476b01c9773b5e06e5fc6a550d3c",
|
89
|
-
"author": {
|
90
|
-
"name": "User Name",
|
91
|
-
"email": "me@example.com"
|
92
|
-
}
|
93
|
-
},
|
94
|
-
{
|
95
|
-
"id": "a1dfcca6369dcbd19607c4cc0f932194d8bdf57d",
|
96
|
-
"message": "Merge branch '96071_merge_ad_campaigns' of gitlab.example.com:sqerp",
|
97
|
-
"timestamp": "2014-01-28T12:10:16+04:00",
|
98
|
-
"url": "https://gitlab.example.com/sqerp/commit/a1dfcca6369dcbd19607c4cc0f932194d8bdf57d",
|
99
|
-
"author": {
|
100
|
-
"name": "User Name",
|
101
|
-
"email": "me@example.com"
|
102
|
-
}
|
103
|
-
}
|
104
|
-
],
|
105
|
-
"total_commits_count": 9
|
106
|
-
}
|
@@ -1,101 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Vx::ServiceConnector::GitlabV4::Payload do
|
4
|
-
let(:content) { read_json_fixture("gitlab_v4/payload/push") }
|
5
|
-
let(:payload) { described_class.new content }
|
6
|
-
subject { payload }
|
7
|
-
|
8
|
-
context "push" do
|
9
|
-
let(:url) { "https://gitlab.example.com/sqerp/commit/4b65377d80364713293df276d7756ff6253eedcd" }
|
10
|
-
|
11
|
-
its(:pull_request?) { should be_false }
|
12
|
-
its(:pull_request_number) { should be_nil }
|
13
|
-
its(:head) { should eq 'a1dfcca6369dcbd19607c4cc0f932194d8bdf57d' }
|
14
|
-
its(:base) { should eq 'e9f2a24318cf0a08dc2d7b987b9d8484e8c89406' }
|
15
|
-
its(:branch) { should eq 'master' }
|
16
|
-
its(:branch_label) { should eq 'master' }
|
17
|
-
its(:url) { should eq url }
|
18
|
-
|
19
|
-
its(:pull_request_head_repo_id){ should be_nil }
|
20
|
-
its(:pull_request_base_repo_id){ should be_nil }
|
21
|
-
end
|
22
|
-
|
23
|
-
context "pull_request" do
|
24
|
-
let(:content) { read_json_fixture("gitlab_v4/payload/merge_request1_unchecked") }
|
25
|
-
|
26
|
-
its(:pull_request?) { should be_true }
|
27
|
-
its(:pull_request_number) { should eq 1 }
|
28
|
-
its(:ignore?) { should be_false }
|
29
|
-
its(:head) { should eq 'd0862adb2c46aecb3db4cb4a50867599e4015cf9' }
|
30
|
-
its(:base) { should eq 'f1f92a4ef47a4257973282718449154938c3684d' }
|
31
|
-
its(:branch) { should eq 'one' }
|
32
|
-
its(:url) { should be_nil }
|
33
|
-
end
|
34
|
-
|
35
|
-
context "tag?" do
|
36
|
-
end
|
37
|
-
|
38
|
-
context "closed_pull_request?" do
|
39
|
-
end
|
40
|
-
|
41
|
-
context "foreign_pull_request?" do
|
42
|
-
end
|
43
|
-
|
44
|
-
=begin
|
45
|
-
context "ignore?" do
|
46
|
-
subject { payload.ignore? }
|
47
|
-
|
48
|
-
context "when pull request" do
|
49
|
-
let(:content) { read_json_fixture("github/payload/foreign_pull_request") }
|
50
|
-
it { should be_false}
|
51
|
-
|
52
|
-
context "and is closed" do
|
53
|
-
before do
|
54
|
-
expect(payload).to receive(:closed_pull_request?) { true }
|
55
|
-
end
|
56
|
-
it { should be_true }
|
57
|
-
end
|
58
|
-
|
59
|
-
context "and same repo" do
|
60
|
-
let(:content) { read_json_fixture("github/payload/pull_request") }
|
61
|
-
it { should be_true }
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context "when regular commit" do
|
66
|
-
it { should be_false }
|
67
|
-
|
68
|
-
context "and deleted branch" do
|
69
|
-
before do
|
70
|
-
expect(payload).to receive(:head) { '0000000000000000000000000000000000000000' }
|
71
|
-
end
|
72
|
-
it { should be_true }
|
73
|
-
end
|
74
|
-
|
75
|
-
context "and tag created" do
|
76
|
-
before do
|
77
|
-
expect(payload).to receive(:tag?) { true }
|
78
|
-
end
|
79
|
-
it { should be_true }
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
=end
|
84
|
-
|
85
|
-
context "to_model" do
|
86
|
-
subject { payload.to_model }
|
87
|
-
it { should be_instance_of(Vx::ServiceConnector::Model::Payload) }
|
88
|
-
|
89
|
-
its(:values) { should eq(
|
90
|
-
[false,
|
91
|
-
nil,
|
92
|
-
"a1dfcca6369dcbd19607c4cc0f932194d8bdf57d",
|
93
|
-
"e9f2a24318cf0a08dc2d7b987b9d8484e8c89406",
|
94
|
-
"master",
|
95
|
-
"master",
|
96
|
-
"https://gitlab.example.com/sqerp/commit/4b65377d80364713293df276d7756ff6253eedcd",
|
97
|
-
false]
|
98
|
-
) }
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|