vx-service_connector 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vx/service_connector.rb +3 -0
- data/lib/vx/service_connector/gitlab_v5.rb +7 -7
- data/lib/vx/service_connector/gitlab_v5/hooks.rb +5 -1
- data/lib/vx/service_connector/gitlab_v5/payload.rb +10 -2
- data/lib/vx/service_connector/gitlab_v6.rb +10 -0
- data/lib/vx/service_connector/gitlab_v6/deploy_keys.rb +7 -0
- data/lib/vx/service_connector/gitlab_v6/files.rb +8 -0
- data/lib/vx/service_connector/gitlab_v6/hooks.rb +11 -0
- data/lib/vx/service_connector/gitlab_v6/notices.rb +6 -0
- data/lib/vx/service_connector/gitlab_v6/payload.rb +105 -0
- data/lib/vx/service_connector/gitlab_v6/repos.rb +6 -0
- data/lib/vx/service_connector/gitlab_v6/session.rb +9 -0
- data/lib/vx/service_connector/version.rb +1 -1
- data/spec/fixtures/gitlab_v6/branch.json +22 -0
- data/spec/fixtures/gitlab_v6/commit.json +11 -0
- data/spec/fixtures/gitlab_v6/commits.json +10 -0
- data/spec/fixtures/gitlab_v6/deploy_keys.json +14 -0
- data/spec/fixtures/gitlab_v6/hooks.json +11 -0
- data/spec/fixtures/gitlab_v6/payload/closed_merge_request.json +20 -0
- data/spec/fixtures/gitlab_v6/payload/merge_request.json +20 -0
- data/spec/fixtures/gitlab_v6/payload/push.json +25 -0
- data/spec/fixtures/gitlab_v6/payload/push_tag.json +14 -0
- data/spec/fixtures/gitlab_v6/project.json +46 -0
- data/spec/fixtures/gitlab_v6/projects.json +41 -0
- data/spec/lib/gitlab_payload_spec.rb +35 -0
- data/spec/lib/gitlab_spec.rb +122 -0
- data/spec/lib/gitlab_v6_payload_spec.rb +56 -0
- data/spec/lib/service_connector_spec.rb +5 -0
- data/spec/support/gitlab_v5_spec_helpers.rb +5 -0
- data/spec/support/gitlab_v5_web_mocks.rb +7 -58
- data/spec/support/gitlab_v6_spec_helpers.rb +5 -0
- data/spec/support/gitlab_v6_web_mocks.rb +34 -0
- data/spec/support/gitlab_web_mocks.rb +56 -0
- metadata +46 -6
- data/spec/lib/gitlab_v5_payload_spec.rb +0 -33
- data/spec/lib/gitlab_v5_spec.rb +0 -117
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6bb570ebaae300ece69aeaa8af1fff7ad89a596
|
4
|
+
data.tar.gz: fc9b789a77f95b4ce64fa55b3c2749b230e72291
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dca5c56992692538e9017f9567ac9d261fc1ef3b784e598f8bbd0261d3b9e2a48fd8a80345c11e3045910b15f54ef4050ffea0f20add623d4b683f40977b4ab
|
7
|
+
data.tar.gz: c2ccf1066633abf7a69cd05e7753baac3cafb8e5dc71ef74dc5fb9d0a909d98a5beefd1606cb7d27a7cef5aba9cdd6d4be7e54ce17a75769d1c9d6c72654567f
|
data/lib/vx/service_connector.rb
CHANGED
@@ -8,6 +8,7 @@ module Vx
|
|
8
8
|
autoload :Base, File.expand_path("../service_connector/base", __FILE__)
|
9
9
|
autoload :Github, File.expand_path("../service_connector/github", __FILE__)
|
10
10
|
autoload :GitlabV5, File.expand_path("../service_connector/gitlab_v5", __FILE__)
|
11
|
+
autoload :GitlabV6, File.expand_path("../service_connector/gitlab_v6", __FILE__)
|
11
12
|
autoload :Model, File.expand_path("../service_connector/model", __FILE__)
|
12
13
|
|
13
14
|
extend self
|
@@ -18,6 +19,8 @@ module Vx
|
|
18
19
|
Github
|
19
20
|
when :gitlab_v5
|
20
21
|
GitlabV5
|
22
|
+
when :gitlab_v6
|
23
|
+
GitlabV6
|
21
24
|
else
|
22
25
|
raise ArgumentError, "Serivice for #{name.inspect} is not defined"
|
23
26
|
end
|
@@ -5,7 +5,7 @@ module Vx
|
|
5
5
|
include ServiceConnector::Base
|
6
6
|
|
7
7
|
def repos
|
8
|
-
@repos ||=
|
8
|
+
@repos ||= self.class::Repos.new(session).to_a
|
9
9
|
end
|
10
10
|
|
11
11
|
def organizations
|
@@ -13,29 +13,29 @@ module Vx
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def hooks(repo)
|
16
|
-
|
16
|
+
self.class::Hooks.new(session, repo)
|
17
17
|
end
|
18
18
|
|
19
19
|
def deploy_keys(repo)
|
20
|
-
|
20
|
+
self.class::DeployKeys.new(session, repo)
|
21
21
|
end
|
22
22
|
|
23
23
|
def notices(repo)
|
24
|
-
|
24
|
+
self.class::Notices.new(session, repo)
|
25
25
|
end
|
26
26
|
|
27
27
|
def files(repo)
|
28
|
-
|
28
|
+
self.class::Files.new(session, repo)
|
29
29
|
end
|
30
30
|
|
31
31
|
def payload(repo, params)
|
32
|
-
|
32
|
+
self.class::Payload.new(session, repo, params).build
|
33
33
|
end
|
34
34
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def create_session
|
38
|
-
|
38
|
+
self.class::Session.new(endpoint, private_token)
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
@@ -24,7 +24,7 @@ module Vx
|
|
24
24
|
all.select do |hook|
|
25
25
|
hook.url =~ /#{Regexp.escape url_mask}/
|
26
26
|
end.map do |hook|
|
27
|
-
session.delete
|
27
|
+
session.delete hook_url(hook.id)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -34,6 +34,10 @@ module Vx
|
|
34
34
|
"/projects/#{repo.id}/hooks"
|
35
35
|
end
|
36
36
|
|
37
|
+
def hook_url(id)
|
38
|
+
"#{hooks_url}?hook_id=#{id}"
|
39
|
+
end
|
40
|
+
|
37
41
|
end
|
38
42
|
end
|
39
43
|
end
|
@@ -79,7 +79,11 @@ module Vx
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def ignore?
|
82
|
-
|
82
|
+
if pull_request?
|
83
|
+
closed_pull_request? || !foreign_pull_request?
|
84
|
+
else
|
85
|
+
sha == '0000000000000000000000000000000000000000' || tag?
|
86
|
+
end
|
83
87
|
end
|
84
88
|
|
85
89
|
def pull_request
|
@@ -97,7 +101,7 @@ module Vx
|
|
97
101
|
def commit_for_payload
|
98
102
|
@commit_for_payload ||=
|
99
103
|
begin
|
100
|
-
commits = session.get(
|
104
|
+
commits = session.get(commit_uri(repo.id, sha))
|
101
105
|
commits.first || {}
|
102
106
|
rescue RequestError => e
|
103
107
|
$stderr.puts "ERROR: #{e.inspect}"
|
@@ -105,6 +109,10 @@ module Vx
|
|
105
109
|
end
|
106
110
|
end
|
107
111
|
|
112
|
+
def commit_uri(repo_id, sha)
|
113
|
+
"/projects/#{repo_id}/repository/commits?ref_name=#{sha}"
|
114
|
+
end
|
115
|
+
|
108
116
|
end
|
109
117
|
|
110
118
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module Vx
|
2
|
+
module ServiceConnector
|
3
|
+
class GitlabV6::Payload < GitlabV5::Payload
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def pull_request?
|
8
|
+
self["object_kind"] == "merge_request"
|
9
|
+
end
|
10
|
+
|
11
|
+
def tag?
|
12
|
+
!pull_request? && self["ref"].start_with?("refs/tags/")
|
13
|
+
end
|
14
|
+
|
15
|
+
def pull_request_number
|
16
|
+
if pull_request?
|
17
|
+
pull_request["iid"]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def pull_request_head_repo_id
|
22
|
+
if pull_request?
|
23
|
+
pull_request["source_project_id"]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def web_url
|
28
|
+
if pull_request?
|
29
|
+
base_url = project_details["web_url"]
|
30
|
+
id = pull_request["iid"]
|
31
|
+
|
32
|
+
"#{base_url}/merge_requests/#{id}"
|
33
|
+
|
34
|
+
elsif u = self["repository"] && self["repository"]["homepage"]
|
35
|
+
"#{u}/commit/#{sha}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def pull_request_base_repo_id
|
40
|
+
if pull_request?
|
41
|
+
pull_request["target_project_id"]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def sha
|
46
|
+
if pull_request?
|
47
|
+
commit_sha_for_pull_request
|
48
|
+
else
|
49
|
+
self["after"]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def closed_pull_request?
|
54
|
+
pull_request? && (%w(closed merged).include? pull_request["state"].to_s)
|
55
|
+
end
|
56
|
+
|
57
|
+
def pull_request
|
58
|
+
if pull_request?
|
59
|
+
self["object_attributes"]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def project_details
|
64
|
+
@project_details ||= begin
|
65
|
+
project = session.get("/projects/#{repo.id}")
|
66
|
+
rescue RequestError => e
|
67
|
+
$stderr.puts "ERROR: #{e.inspect}"
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def commit_sha_for_pull_request
|
73
|
+
@commit_sha ||= begin
|
74
|
+
branch_details = session.get("/projects/#{repo.id}/repository/branches/#{branch}")
|
75
|
+
branch_details["commit"]["id"]
|
76
|
+
rescue RequestError => e
|
77
|
+
$stderr.puts "ERROR: #{e.inspect}"
|
78
|
+
nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def branch
|
83
|
+
if pull_request?
|
84
|
+
pull_request["source_branch"]
|
85
|
+
else
|
86
|
+
self["ref"].to_s.split("refs/heads/").last
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def commit_for_payload
|
91
|
+
@commit_for_payload ||=
|
92
|
+
begin
|
93
|
+
commit = session.get(commit_uri(repo.id, sha))
|
94
|
+
rescue RequestError => e
|
95
|
+
$stderr.puts "ERROR: #{e.inspect}"
|
96
|
+
{}
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def commit_uri(repo_id, sha)
|
101
|
+
"/projects/#{repo_id}/repository/commits/#{sha}"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"name": "some-branch-name",
|
3
|
+
"commit": {
|
4
|
+
"id": "a7c31647c6449c3d98c4027d97e00b3048ac3bbf",
|
5
|
+
"parents": [{
|
6
|
+
"id": "aa7544c196ccf44a24e21c9aed12a0b246919fe0"
|
7
|
+
}],
|
8
|
+
"tree": "c5752d5f3b43e847f4f7fd0cdfdd1259e5009d45",
|
9
|
+
"message": "hhh",
|
10
|
+
"author": {
|
11
|
+
"name": "John Doe",
|
12
|
+
"email": "john@doe.com"
|
13
|
+
},
|
14
|
+
"committer": {
|
15
|
+
"name": "John Doe",
|
16
|
+
"email": "john@doe.com"
|
17
|
+
},
|
18
|
+
"authored_date": "2014-04-02T23:40:31-07:00",
|
19
|
+
"committed_date": "2014-04-03T02:40:29-07:00"
|
20
|
+
},
|
21
|
+
"protected": false
|
22
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"id": "2dd0fdf94c7d0a74921e178b3b5229e60ce5d03e",
|
3
|
+
"short_id": "2dd0fdf94c7",
|
4
|
+
"title": "Replace sanitize with escape once",
|
5
|
+
"author_name": "Dmitriy Zaporozhets",
|
6
|
+
"author_email": "dzaporozhets@sphereconsultinginc.com",
|
7
|
+
"created_at": "2014-04-03T03:06:13-07:00",
|
8
|
+
"parent_ids": ["3a974a1e369bf2b16ee41d925cf3d2d44842d0d0"],
|
9
|
+
"committed_date": "2014-04-03T03:06:13-07:00",
|
10
|
+
"authored_date": "2014-04-03T03:06:13-07:00"
|
11
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": "2dd0fdf94c7d0a74921e178b3b5229e60ce5d03e",
|
4
|
+
"short_id": "2dd0fdf94c7",
|
5
|
+
"title": "Replace sanitize with escape once",
|
6
|
+
"author_name": "Dmitriy Zaporozhets",
|
7
|
+
"author_email": "dzaporozhets@sphereconsultinginc.com",
|
8
|
+
"created_at": "2014-04-03T03:06:13-07:00"
|
9
|
+
}
|
10
|
+
]
|
@@ -0,0 +1,14 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": 1,
|
4
|
+
"title" : "Public key",
|
5
|
+
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=",
|
6
|
+
"created_at":"2013-10-02T10:12:29Z"
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"id": 3,
|
10
|
+
"title" : "me@example.com",
|
11
|
+
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=",
|
12
|
+
"created_at":"2013-10-02T11:12:29Z"
|
13
|
+
}
|
14
|
+
]
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"object_kind": "merge_request",
|
3
|
+
"object_attributes": {
|
4
|
+
"id": 5,
|
5
|
+
"target_branch": "master",
|
6
|
+
"source_branch": "some-branch-name",
|
7
|
+
"source_project_id": 2,
|
8
|
+
"author_id": 1,
|
9
|
+
"assignee_id": 1,
|
10
|
+
"title": "Uiu",
|
11
|
+
"created_at": "2014-04-03T10:04:12.153Z",
|
12
|
+
"updated_at": "2014-04-03T10:04:18.012Z",
|
13
|
+
"milestone_id": null,
|
14
|
+
"state": "closed",
|
15
|
+
"merge_status": "can_be_merged",
|
16
|
+
"target_project_id": 2,
|
17
|
+
"iid": 5,
|
18
|
+
"description": "some desc..."
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"object_kind": "merge_request",
|
3
|
+
"object_attributes": {
|
4
|
+
"id": 5,
|
5
|
+
"target_branch": "master",
|
6
|
+
"source_branch": "some-branch-name",
|
7
|
+
"source_project_id": 2,
|
8
|
+
"author_id": 1,
|
9
|
+
"assignee_id": 1,
|
10
|
+
"title": "Uiu",
|
11
|
+
"created_at": "2014-04-03T10:04:12.153Z",
|
12
|
+
"updated_at": "2014-04-03T10:04:12.153Z",
|
13
|
+
"milestone_id": null,
|
14
|
+
"state": "opened",
|
15
|
+
"merge_status": "unchecked",
|
16
|
+
"target_project_id": 2,
|
17
|
+
"iid": 5,
|
18
|
+
"description": "some desc..."
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"before": "0000000000000000000000000000000000000000",
|
3
|
+
"after": "decc3915e29d7ae1786bb981b2ea3702afae592a",
|
4
|
+
"ref": "refs/heads/testing",
|
5
|
+
"user_id": 13,
|
6
|
+
"user_name": "Dmitry",
|
7
|
+
"project_id": 1,
|
8
|
+
"repository": {
|
9
|
+
"name": "event_generator",
|
10
|
+
"url": "git@git.dev.gorod-skidok.com:serverist2/event_generator.git",
|
11
|
+
"description": "",
|
12
|
+
"homepage": "http://git.dev.gorod-skidok.com/serverist2/event_generator"
|
13
|
+
},
|
14
|
+
"commits": [{
|
15
|
+
"id": "decc3915e29d7ae1786bb981b2ea3702afae592a",
|
16
|
+
"message": "test",
|
17
|
+
"timestamp": "2014-04-02T23:40:31-07:00",
|
18
|
+
"url": "http://git.dev.gorod-skidok.com/serverist2/event_generator/commit/decc3915e29d7ae1786bb981b2ea3702afae592a",
|
19
|
+
"author": {
|
20
|
+
"name": "Dmitry",
|
21
|
+
"email": "some@mail.com"
|
22
|
+
}
|
23
|
+
}],
|
24
|
+
"total_commits_count": 1
|
25
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"ref": "refs/tags/v1",
|
3
|
+
"before": "0000000000000000000000000000000000000000",
|
4
|
+
"after": "decc3915e29d7ae1786bb981b2ea3702afae592a",
|
5
|
+
"user_id": 1,
|
6
|
+
"user_name": "Administrator",
|
7
|
+
"project_id": 2,
|
8
|
+
"repository": {
|
9
|
+
"name": "seopl",
|
10
|
+
"url": "git@localhost:root/seopl.git",
|
11
|
+
"description": "",
|
12
|
+
"homepage": "http://localhost/root/seopl"
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
{
|
2
|
+
"id": 2,
|
3
|
+
"description": "",
|
4
|
+
"default_branch": "master",
|
5
|
+
"public": true,
|
6
|
+
"visibility_level": 20,
|
7
|
+
"ssh_url_to_repo": "git@localhost:example/sqerp.git",
|
8
|
+
"http_url_to_repo": "http://localhost/example/sqerp.git",
|
9
|
+
"web_url": "http://localhost/example/sqerp",
|
10
|
+
"owner": {
|
11
|
+
"id": 1,
|
12
|
+
"username": "root",
|
13
|
+
"email": "admin@local.host",
|
14
|
+
"name": "Administrator",
|
15
|
+
"state": "active",
|
16
|
+
"created_at": "2014-03-24T15:45:56.548Z"
|
17
|
+
},
|
18
|
+
"name": "sqerp",
|
19
|
+
"name_with_namespace": "Administrator / sqerp",
|
20
|
+
"path": "sqerp",
|
21
|
+
"path_with_namespace": "example/sqerp",
|
22
|
+
"issues_enabled": true,
|
23
|
+
"merge_requests_enabled": true,
|
24
|
+
"wall_enabled": false,
|
25
|
+
"wiki_enabled": true,
|
26
|
+
"snippets_enabled": false,
|
27
|
+
"created_at": "2014-04-03T09:37:48.838Z",
|
28
|
+
"last_activity_at": "2014-04-03T14:06:02.254Z",
|
29
|
+
"namespace": {
|
30
|
+
"id": 1,
|
31
|
+
"name": "root",
|
32
|
+
"path": "root",
|
33
|
+
"owner_id": 1,
|
34
|
+
"created_at": "2014-03-24T15:45:56.691Z",
|
35
|
+
"updated_at": "2014-03-24T15:45:56.691Z",
|
36
|
+
"description": "",
|
37
|
+
"avatar": null
|
38
|
+
},
|
39
|
+
"permissions": {
|
40
|
+
"project_access": {
|
41
|
+
"access_level": 40,
|
42
|
+
"notification_level": 3
|
43
|
+
},
|
44
|
+
"group_access": null
|
45
|
+
}
|
46
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": 9,
|
4
|
+
"description": "",
|
5
|
+
"default_branch": "master",
|
6
|
+
"public": false,
|
7
|
+
"visibility_level": 20,
|
8
|
+
"ssh_url_to_repo": "git@example.com:example/sqerp.git",
|
9
|
+
"http_url_to_repo": "http://example.com:80/example/sqerp.git",
|
10
|
+
"web_url": "http://example.com:80/example/sqerp",
|
11
|
+
"owner": {
|
12
|
+
"id": 1,
|
13
|
+
"username": "root",
|
14
|
+
"email": "admin@local.host",
|
15
|
+
"name": "Administrator",
|
16
|
+
"state": "active",
|
17
|
+
"created_at": "2014-03-24T15:45:56.548Z"
|
18
|
+
},
|
19
|
+
"name": "sqerp",
|
20
|
+
"name_with_namespace": "Administrator / sqerp",
|
21
|
+
"path": "sqerp",
|
22
|
+
"path_with_namespace": "example/sqerp",
|
23
|
+
"issues_enabled": true,
|
24
|
+
"merge_requests_enabled": true,
|
25
|
+
"wall_enabled": false,
|
26
|
+
"wiki_enabled": true,
|
27
|
+
"snippets_enabled": false,
|
28
|
+
"created_at": "2014-04-03T09:37:48.838Z",
|
29
|
+
"last_activity_at": "2014-04-03T10:06:15.587Z",
|
30
|
+
"namespace": {
|
31
|
+
"id": 1,
|
32
|
+
"name": "root",
|
33
|
+
"path": "root",
|
34
|
+
"owner_id": 1,
|
35
|
+
"created_at": "2014-03-24T15:45:56.691Z",
|
36
|
+
"updated_at": "2014-03-24T15:45:56.691Z",
|
37
|
+
"description": "",
|
38
|
+
"avatar": null
|
39
|
+
}
|
40
|
+
}
|
41
|
+
]
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
[5, 6].each do |version|
|
4
|
+
gitlab_version = "GitlabV#{version}"
|
5
|
+
describe Vx::ServiceConnector.const_get(gitlab_version)::Payload do
|
6
|
+
|
7
|
+
include const_get("#{gitlab_version}WebMocks")
|
8
|
+
|
9
|
+
let(:content) { read_json_fixture("gitlab_v#{version}/payload/push") }
|
10
|
+
let(:repo) { create :repo }
|
11
|
+
let(:gitlab) { Vx::ServiceConnector.const_get(gitlab_version).new 'http://example.com', 'token' }
|
12
|
+
let(:payload) { gitlab.payload(repo, content) }
|
13
|
+
subject { payload }
|
14
|
+
|
15
|
+
context "push" do
|
16
|
+
let(:sha) { 'decc3915e29d7ae1786bb981b2ea3702afae592a' }
|
17
|
+
let(:url) { "http://git.dev.gorod-skidok.com/serverist2/event_generator/commit/decc3915e29d7ae1786bb981b2ea3702afae592a" }
|
18
|
+
|
19
|
+
before do
|
20
|
+
mock_get_commit 1, sha
|
21
|
+
end
|
22
|
+
|
23
|
+
its(:pull_request?) { should be_false }
|
24
|
+
its(:pull_request_number) { should be_nil }
|
25
|
+
its(:sha) { should eq sha }
|
26
|
+
its(:branch) { should eq 'testing' }
|
27
|
+
its(:branch_label) { should eq 'testing' }
|
28
|
+
its(:message) { should eq 'Replace sanitize with escape once' }
|
29
|
+
its(:author) { should eq 'Dmitriy Zaporozhets' }
|
30
|
+
its(:author_email) { should eq 'dzaporozhets@sphereconsultinginc.com' }
|
31
|
+
its(:web_url) { should eq url }
|
32
|
+
its(:ignore?) { should be_false }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
[5, 6].each do |version|
|
4
|
+
klass = Vx::ServiceConnector.const_get("GitlabV#{version}")
|
5
|
+
describe klass do
|
6
|
+
require_relative "../support/gitlab_v#{version}_spec_helpers"
|
7
|
+
include const_get("GitlabV#{version}SpecHelpers")
|
8
|
+
|
9
|
+
include const_get("GitlabV#{version}WebMocks")
|
10
|
+
|
11
|
+
let(:endpoint) { 'http://example.com' }
|
12
|
+
let(:token) { 'token' }
|
13
|
+
let(:repo) { create :repo }
|
14
|
+
let(:gitlab) { described_class.new endpoint, token }
|
15
|
+
|
16
|
+
subject { gitlab }
|
17
|
+
|
18
|
+
it { should be }
|
19
|
+
|
20
|
+
context "(notices)" do
|
21
|
+
let(:notices) { gitlab.notices(repo) }
|
22
|
+
|
23
|
+
context "create" do
|
24
|
+
subject { notices.create nil, nil, nil, nil }
|
25
|
+
it { should be :not_available }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "(repos)" do
|
30
|
+
subject { gitlab.repos }
|
31
|
+
|
32
|
+
before do
|
33
|
+
mock_repos
|
34
|
+
end
|
35
|
+
|
36
|
+
it { should have(1).item }
|
37
|
+
|
38
|
+
context "values" do
|
39
|
+
subject { gitlab.repos.map(&:values) }
|
40
|
+
it { should eq(
|
41
|
+
project_list
|
42
|
+
) }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "(deploy_keys)" do
|
47
|
+
let(:key_name) { 'me@example.com' }
|
48
|
+
let(:public_key) { 'public key' }
|
49
|
+
let(:deploy_keys) { gitlab.deploy_keys(repo) }
|
50
|
+
|
51
|
+
context "all" do
|
52
|
+
subject { deploy_keys.all }
|
53
|
+
before { mock_deploy_keys }
|
54
|
+
it { should have(2).items }
|
55
|
+
end
|
56
|
+
|
57
|
+
context "create" do
|
58
|
+
subject { deploy_keys.create key_name, public_key }
|
59
|
+
before { mock_add_deploy_key }
|
60
|
+
it { should be }
|
61
|
+
end
|
62
|
+
|
63
|
+
context "destroy" do
|
64
|
+
subject { deploy_keys.destroy key_name }
|
65
|
+
before do
|
66
|
+
mock_deploy_keys
|
67
|
+
mock_delete_deploy_key
|
68
|
+
end
|
69
|
+
|
70
|
+
it { should have(1).item }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "(hooks)" do
|
75
|
+
let(:url) { 'url' }
|
76
|
+
let(:token) { 'token' }
|
77
|
+
let(:hooks) { gitlab.hooks(repo) }
|
78
|
+
|
79
|
+
context "all" do
|
80
|
+
subject { hooks.all }
|
81
|
+
before { mock_hooks }
|
82
|
+
it { should have(1).item }
|
83
|
+
end
|
84
|
+
|
85
|
+
context "create" do
|
86
|
+
subject { hooks.create url, token }
|
87
|
+
before { mock_add_hook }
|
88
|
+
it { should be }
|
89
|
+
end
|
90
|
+
|
91
|
+
context "destroy" do
|
92
|
+
let(:mask) { "http://example.com" }
|
93
|
+
subject { hooks.destroy mask }
|
94
|
+
before do
|
95
|
+
mock_hooks
|
96
|
+
mock_remove_hook
|
97
|
+
end
|
98
|
+
it { should have(1).item }
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "(files)" do
|
103
|
+
let(:sha) { 'sha' }
|
104
|
+
let(:path) { 'path' }
|
105
|
+
|
106
|
+
context "get" do
|
107
|
+
subject { gitlab.files(repo).get sha, path }
|
108
|
+
|
109
|
+
context "success" do
|
110
|
+
before { mock_get_file }
|
111
|
+
it { should eq 'content' }
|
112
|
+
end
|
113
|
+
|
114
|
+
context "not found" do
|
115
|
+
before { mock_get_file_not_found }
|
116
|
+
it { should be_nil }
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vx::ServiceConnector::GitlabV6::Payload do
|
4
|
+
|
5
|
+
include const_get("GitlabV6WebMocks")
|
6
|
+
|
7
|
+
let(:content) { read_json_fixture("gitlab_v6/payload/push") }
|
8
|
+
let(:repo) { create :repo }
|
9
|
+
let(:gitlab) { Vx::ServiceConnector::GitlabV6.new 'http://example.com', 'token' }
|
10
|
+
let(:payload) { gitlab.payload(repo, content) }
|
11
|
+
subject { payload }
|
12
|
+
|
13
|
+
context "pull_request" do
|
14
|
+
let(:content) { read_json_fixture("gitlab_v6/payload/merge_request") }
|
15
|
+
let(:sha) { 'a7c31647c6449c3d98c4027d97e00b3048ac3bbf' }
|
16
|
+
|
17
|
+
before do
|
18
|
+
mock_get_commit 1, sha
|
19
|
+
mock_branch 1, "some-branch-name"
|
20
|
+
mock_project 1
|
21
|
+
end
|
22
|
+
|
23
|
+
its(:pull_request?) { should be_true }
|
24
|
+
its(:pull_request_number) { should eq 5 }
|
25
|
+
its(:sha) { should eq sha }
|
26
|
+
its(:branch) { should eq 'some-branch-name' }
|
27
|
+
its(:message) { should eq 'Replace sanitize with escape once' }
|
28
|
+
its(:author) { should eq 'Dmitriy Zaporozhets' }
|
29
|
+
its(:author_email) { should eq 'dzaporozhets@sphereconsultinginc.com' }
|
30
|
+
its(:web_url) { should eq "http://localhost/example/sqerp/merge_requests/5" }
|
31
|
+
its(:ignore?) { should be_true }
|
32
|
+
end
|
33
|
+
|
34
|
+
context "push tag" do
|
35
|
+
let(:sha) { 'decc3915e29d7ae1786bb981b2ea3702afae592a' }
|
36
|
+
|
37
|
+
before do
|
38
|
+
mock_get_tag 1, sha
|
39
|
+
end
|
40
|
+
|
41
|
+
let(:content) { read_json_fixture("gitlab_v6/payload/push_tag") }
|
42
|
+
its(:ignore?) { should be_true }
|
43
|
+
end
|
44
|
+
|
45
|
+
context "closed pull request" do
|
46
|
+
let(:content) { read_json_fixture("gitlab_v6/payload/closed_merge_request") }
|
47
|
+
|
48
|
+
before do
|
49
|
+
mock_get_commit 1, 'a7c31647c6449c3d98c4027d97e00b3048ac3bbf'
|
50
|
+
mock_branch 1, "some-branch-name"
|
51
|
+
mock_project 1
|
52
|
+
end
|
53
|
+
|
54
|
+
its(:ignore?) { should be_true }
|
55
|
+
end
|
56
|
+
end
|
@@ -1,54 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
def mock_repos
|
4
|
-
mock_get "projects?per_page=30", 'projects'
|
5
|
-
end
|
6
|
-
|
7
|
-
def mock_deploy_keys
|
8
|
-
mock_get "projects/1/keys", 'deploy_keys'
|
9
|
-
end
|
10
|
-
|
11
|
-
def mock_add_deploy_key
|
12
|
-
mock_post "projects/1/keys", '{"title":"me@example.com","key":"public key"}'
|
13
|
-
end
|
14
|
-
|
15
|
-
def mock_delete_deploy_key
|
16
|
-
mock_delete "projects/1/keys/3", nil
|
17
|
-
end
|
18
|
-
|
19
|
-
def mock_add_hook
|
20
|
-
mock_post "projects/1/hooks", "{\"url\":\"url\",\"push_events\":true,\"merge_requests_events\":true}"
|
21
|
-
end
|
22
|
-
|
23
|
-
def mock_remove_hook
|
24
|
-
mock_delete "projects/1/hooks?hook_id=57", ""
|
25
|
-
end
|
1
|
+
require_relative "gitlab_web_mocks"
|
26
2
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
def mock_get_file
|
32
|
-
stub_request(:get, "http://example.com/api/v3/projects/1/repository/commits/sha/blob?filepath=path").
|
33
|
-
with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json', 'Private-Token'=>'token'}).
|
34
|
-
to_return(:status => 200, :body => "content")
|
35
|
-
end
|
36
|
-
|
37
|
-
def mock_get_file_not_found
|
38
|
-
stub_request(:get, "http://example.com/api/v3/projects/1/repository/commits/sha/blob?filepath=path").
|
39
|
-
with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json', 'Private-Token'=>'token'}).
|
40
|
-
to_return(:status => 404, :body => "")
|
41
|
-
end
|
42
|
-
|
43
|
-
def mock_get_commit(pid, sha)
|
44
|
-
mock_get "projects/#{pid}/repository/commits?ref_name=#{sha}", 'commits'
|
45
|
-
end
|
46
|
-
|
47
|
-
def mock_get_commit_not_found
|
48
|
-
stub_request(:get, "http://example.com/api/v3/projects/1/repository/commits?ref_name=sha").
|
49
|
-
with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json', 'Private-Token'=>'token'}).
|
50
|
-
to_return(:status => 404, :body => "")
|
51
|
-
end
|
3
|
+
module GitlabV5WebMocks
|
4
|
+
include GitlabWebMocks
|
52
5
|
|
53
6
|
def mock_get(url, fixture)
|
54
7
|
stub_request(:get, "http://example.com/api/v3/#{url}").
|
@@ -59,15 +12,11 @@ module GitlabV5WebMocks
|
|
59
12
|
:headers => {'Content-Type' => 'application/json'})
|
60
13
|
end
|
61
14
|
|
62
|
-
def
|
63
|
-
|
64
|
-
with(:headers => {'Accept'=>'application/json', }, body: body).
|
65
|
-
to_return(:status => 200, :body => "{}", :headers => {'Content-Type' => 'application/json'})
|
15
|
+
def mock_remove_hook
|
16
|
+
mock_delete "projects/1/hooks?hook_id=57", ""
|
66
17
|
end
|
67
18
|
|
68
|
-
def
|
69
|
-
|
70
|
-
with(:headers => {'Accept'=>'application/json', }, body: body).
|
71
|
-
to_return(:status => 200, :body => "{}", :headers => {'Content-Type' => 'application/json'})
|
19
|
+
def mock_get_commit(pid, sha)
|
20
|
+
mock_get "projects/#{pid}/repository/commits?ref_name=#{sha}", 'commits'
|
72
21
|
end
|
73
22
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative "gitlab_web_mocks"
|
2
|
+
|
3
|
+
module GitlabV6WebMocks
|
4
|
+
include GitlabWebMocks
|
5
|
+
|
6
|
+
def mock_get(url, fixture)
|
7
|
+
stub_request(:get, "http://example.com/api/v3/#{url}").
|
8
|
+
with(:headers => {'Accept'=>'application/json', 'PRIVATE-TOKEN' => "token"}).
|
9
|
+
to_return(
|
10
|
+
:status => 200,
|
11
|
+
:body => read_fixture("gitlab_v6/#{fixture}.json"),
|
12
|
+
:headers => {'Content-Type' => 'application/json'})
|
13
|
+
end
|
14
|
+
|
15
|
+
def mock_remove_hook
|
16
|
+
mock_delete "projects/1/hooks/57", ""
|
17
|
+
end
|
18
|
+
|
19
|
+
def mock_get_commit(pid, sha)
|
20
|
+
mock_get "projects/#{pid}/repository/commits/#{sha}", 'commit'
|
21
|
+
end
|
22
|
+
|
23
|
+
def mock_get_tag(pid, sha)
|
24
|
+
mock_get_commit(pid, sha)
|
25
|
+
end
|
26
|
+
|
27
|
+
def mock_branch(pid, branch_name)
|
28
|
+
mock_get "projects/#{pid}/repository/branches/#{branch_name}", 'branch'
|
29
|
+
end
|
30
|
+
|
31
|
+
def mock_project(pid)
|
32
|
+
mock_get "projects/#{pid}", 'project'
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module GitlabWebMocks
|
2
|
+
|
3
|
+
def mock_repos
|
4
|
+
mock_get "projects?per_page=30", 'projects'
|
5
|
+
end
|
6
|
+
|
7
|
+
def mock_deploy_keys
|
8
|
+
mock_get "projects/1/keys", 'deploy_keys'
|
9
|
+
end
|
10
|
+
|
11
|
+
def mock_add_deploy_key
|
12
|
+
mock_post "projects/1/keys", '{"title":"me@example.com","key":"public key"}'
|
13
|
+
end
|
14
|
+
|
15
|
+
def mock_delete_deploy_key
|
16
|
+
mock_delete "projects/1/keys/3", nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def mock_add_hook
|
20
|
+
mock_post "projects/1/hooks", "{\"url\":\"url\",\"push_events\":true,\"merge_requests_events\":true}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def mock_hooks
|
24
|
+
mock_get "projects/1/hooks", 'hooks'
|
25
|
+
end
|
26
|
+
|
27
|
+
def mock_get_file
|
28
|
+
stub_request(:get, "http://example.com/api/v3/projects/1/repository/commits/sha/blob?filepath=path").
|
29
|
+
with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json', 'Private-Token'=>'token'}).
|
30
|
+
to_return(:status => 200, :body => "content")
|
31
|
+
end
|
32
|
+
|
33
|
+
def mock_get_file_not_found
|
34
|
+
stub_request(:get, "http://example.com/api/v3/projects/1/repository/commits/sha/blob?filepath=path").
|
35
|
+
with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json', 'Private-Token'=>'token'}).
|
36
|
+
to_return(:status => 404, :body => "")
|
37
|
+
end
|
38
|
+
|
39
|
+
def mock_get_commit_not_found
|
40
|
+
stub_request(:get, "http://example.com/api/v3/projects/1/repository/commits?ref_name=sha").
|
41
|
+
with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json', 'Private-Token'=>'token'}).
|
42
|
+
to_return(:status => 404, :body => "")
|
43
|
+
end
|
44
|
+
|
45
|
+
def mock_post(url, body)
|
46
|
+
stub_request(:post, "http://example.com/api/v3/#{url}").
|
47
|
+
with(:headers => {'Accept'=>'application/json', }, body: body).
|
48
|
+
to_return(:status => 200, :body => "{}", :headers => {'Content-Type' => 'application/json'})
|
49
|
+
end
|
50
|
+
|
51
|
+
def mock_delete(url, body)
|
52
|
+
stub_request(:delete, "http://example.com/api/v3/#{url}").
|
53
|
+
with(:headers => {'Accept'=>'application/json', }, body: body).
|
54
|
+
to_return(:status => 200, :body => "{}", :headers => {'Content-Type' => 'application/json'})
|
55
|
+
end
|
56
|
+
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.0.
|
4
|
+
version: 0.0.11
|
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
|
+
date: 2014-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -140,6 +140,14 @@ files:
|
|
140
140
|
- lib/vx/service_connector/gitlab_v5/payload.rb
|
141
141
|
- lib/vx/service_connector/gitlab_v5/repos.rb
|
142
142
|
- lib/vx/service_connector/gitlab_v5/session.rb
|
143
|
+
- lib/vx/service_connector/gitlab_v6.rb
|
144
|
+
- lib/vx/service_connector/gitlab_v6/deploy_keys.rb
|
145
|
+
- lib/vx/service_connector/gitlab_v6/files.rb
|
146
|
+
- lib/vx/service_connector/gitlab_v6/hooks.rb
|
147
|
+
- lib/vx/service_connector/gitlab_v6/notices.rb
|
148
|
+
- lib/vx/service_connector/gitlab_v6/payload.rb
|
149
|
+
- lib/vx/service_connector/gitlab_v6/repos.rb
|
150
|
+
- lib/vx/service_connector/gitlab_v6/session.rb
|
143
151
|
- lib/vx/service_connector/instrumentation.rb
|
144
152
|
- lib/vx/service_connector/model.rb
|
145
153
|
- lib/vx/service_connector/version.rb
|
@@ -163,16 +171,32 @@ files:
|
|
163
171
|
- spec/fixtures/gitlab_v5/payload/push.json
|
164
172
|
- spec/fixtures/gitlab_v5/projects.json
|
165
173
|
- spec/fixtures/gitlab_v5/user_keys.json
|
174
|
+
- spec/fixtures/gitlab_v6/branch.json
|
175
|
+
- spec/fixtures/gitlab_v6/commit.json
|
176
|
+
- spec/fixtures/gitlab_v6/commits.json
|
177
|
+
- spec/fixtures/gitlab_v6/deploy_keys.json
|
178
|
+
- spec/fixtures/gitlab_v6/hooks.json
|
179
|
+
- spec/fixtures/gitlab_v6/payload/closed_merge_request.json
|
180
|
+
- spec/fixtures/gitlab_v6/payload/merge_request.json
|
181
|
+
- spec/fixtures/gitlab_v6/payload/push.json
|
182
|
+
- spec/fixtures/gitlab_v6/payload/push_tag.json
|
183
|
+
- spec/fixtures/gitlab_v6/project.json
|
184
|
+
- spec/fixtures/gitlab_v6/projects.json
|
166
185
|
- spec/lib/github_payload_spec.rb
|
167
186
|
- spec/lib/github_spec.rb
|
168
|
-
- spec/lib/
|
169
|
-
- spec/lib/
|
187
|
+
- spec/lib/gitlab_payload_spec.rb
|
188
|
+
- spec/lib/gitlab_spec.rb
|
189
|
+
- spec/lib/gitlab_v6_payload_spec.rb
|
170
190
|
- spec/lib/model_spec.rb
|
171
191
|
- spec/lib/service_connector_spec.rb
|
172
192
|
- spec/spec_helper.rb
|
173
193
|
- spec/support/create.rb
|
174
194
|
- spec/support/github_web_mocks.rb
|
195
|
+
- spec/support/gitlab_v5_spec_helpers.rb
|
175
196
|
- spec/support/gitlab_v5_web_mocks.rb
|
197
|
+
- spec/support/gitlab_v6_spec_helpers.rb
|
198
|
+
- spec/support/gitlab_v6_web_mocks.rb
|
199
|
+
- spec/support/gitlab_web_mocks.rb
|
176
200
|
- spec/support/read_fixture.rb
|
177
201
|
- vx-service_connector.gemspec
|
178
202
|
homepage: ''
|
@@ -220,14 +244,30 @@ test_files:
|
|
220
244
|
- spec/fixtures/gitlab_v5/payload/push.json
|
221
245
|
- spec/fixtures/gitlab_v5/projects.json
|
222
246
|
- spec/fixtures/gitlab_v5/user_keys.json
|
247
|
+
- spec/fixtures/gitlab_v6/branch.json
|
248
|
+
- spec/fixtures/gitlab_v6/commit.json
|
249
|
+
- spec/fixtures/gitlab_v6/commits.json
|
250
|
+
- spec/fixtures/gitlab_v6/deploy_keys.json
|
251
|
+
- spec/fixtures/gitlab_v6/hooks.json
|
252
|
+
- spec/fixtures/gitlab_v6/payload/closed_merge_request.json
|
253
|
+
- spec/fixtures/gitlab_v6/payload/merge_request.json
|
254
|
+
- spec/fixtures/gitlab_v6/payload/push.json
|
255
|
+
- spec/fixtures/gitlab_v6/payload/push_tag.json
|
256
|
+
- spec/fixtures/gitlab_v6/project.json
|
257
|
+
- spec/fixtures/gitlab_v6/projects.json
|
223
258
|
- spec/lib/github_payload_spec.rb
|
224
259
|
- spec/lib/github_spec.rb
|
225
|
-
- spec/lib/
|
226
|
-
- spec/lib/
|
260
|
+
- spec/lib/gitlab_payload_spec.rb
|
261
|
+
- spec/lib/gitlab_spec.rb
|
262
|
+
- spec/lib/gitlab_v6_payload_spec.rb
|
227
263
|
- spec/lib/model_spec.rb
|
228
264
|
- spec/lib/service_connector_spec.rb
|
229
265
|
- spec/spec_helper.rb
|
230
266
|
- spec/support/create.rb
|
231
267
|
- spec/support/github_web_mocks.rb
|
268
|
+
- spec/support/gitlab_v5_spec_helpers.rb
|
232
269
|
- spec/support/gitlab_v5_web_mocks.rb
|
270
|
+
- spec/support/gitlab_v6_spec_helpers.rb
|
271
|
+
- spec/support/gitlab_v6_web_mocks.rb
|
272
|
+
- spec/support/gitlab_web_mocks.rb
|
233
273
|
- spec/support/read_fixture.rb
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Vx::ServiceConnector::GitlabV5::Payload do
|
4
|
-
|
5
|
-
include GitlabV5WebMocks
|
6
|
-
|
7
|
-
let(:content) { read_json_fixture("gitlab_v5/payload/push") }
|
8
|
-
let(:repo) { create :repo }
|
9
|
-
let(:gitlab) { Vx::ServiceConnector::GitlabV5.new 'http://example.com', 'token' }
|
10
|
-
let(:payload) { gitlab.payload(repo, content) }
|
11
|
-
subject { payload }
|
12
|
-
|
13
|
-
context "push" do
|
14
|
-
let(:sha) { 'decc3915e29d7ae1786bb981b2ea3702afae592a' }
|
15
|
-
let(:url) { "http://git.dev.gorod-skidok.com/serverist2/event_generator/commit/decc3915e29d7ae1786bb981b2ea3702afae592a" }
|
16
|
-
|
17
|
-
before do
|
18
|
-
mock_get_commit 1, sha
|
19
|
-
end
|
20
|
-
|
21
|
-
its(:pull_request?) { should be_false }
|
22
|
-
its(:pull_request_number) { should be_nil }
|
23
|
-
its(:sha) { should eq sha }
|
24
|
-
its(:branch) { should eq 'testing' }
|
25
|
-
its(:branch_label) { should eq 'testing' }
|
26
|
-
its(:message) { should eq 'Replace sanitize with escape once' }
|
27
|
-
its(:author) { should eq 'Dmitriy Zaporozhets' }
|
28
|
-
its(:author_email) { should eq 'dzaporozhets@sphereconsultinginc.com' }
|
29
|
-
its(:web_url) { should eq url }
|
30
|
-
its(:ignore?) { should be_false }
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
data/spec/lib/gitlab_v5_spec.rb
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Vx::ServiceConnector::GitlabV5 do
|
4
|
-
|
5
|
-
include GitlabV5WebMocks
|
6
|
-
|
7
|
-
let(:endpoint) { 'http://example.com' }
|
8
|
-
let(:token) { 'token' }
|
9
|
-
let(:repo) { create :repo }
|
10
|
-
let(:gitlab) { described_class.new endpoint, token }
|
11
|
-
|
12
|
-
subject { gitlab }
|
13
|
-
|
14
|
-
it { should be }
|
15
|
-
|
16
|
-
context "(notices)" do
|
17
|
-
let(:notices) { gitlab.notices(repo) }
|
18
|
-
|
19
|
-
context "create" do
|
20
|
-
subject { notices.create nil, nil, nil, nil }
|
21
|
-
it { should be :not_available }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context "(repos)" do
|
26
|
-
subject { gitlab.repos }
|
27
|
-
|
28
|
-
before do
|
29
|
-
mock_repos
|
30
|
-
end
|
31
|
-
|
32
|
-
it { should have(1).item }
|
33
|
-
|
34
|
-
context "values" do
|
35
|
-
subject { gitlab.repos.map(&:values) }
|
36
|
-
it { should eq(
|
37
|
-
[[9, "example/sqerp", true, "git@example.com:sqerp.git", "http://example.com:80/sqerp", nil]]
|
38
|
-
) }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "(deploy_keys)" do
|
43
|
-
let(:key_name) { 'me@example.com' }
|
44
|
-
let(:public_key) { 'public key' }
|
45
|
-
let(:deploy_keys) { gitlab.deploy_keys(repo) }
|
46
|
-
|
47
|
-
context "all" do
|
48
|
-
subject { deploy_keys.all }
|
49
|
-
before { mock_deploy_keys }
|
50
|
-
it { should have(2).items }
|
51
|
-
end
|
52
|
-
|
53
|
-
context "create" do
|
54
|
-
subject { deploy_keys.create key_name, public_key }
|
55
|
-
before { mock_add_deploy_key }
|
56
|
-
it { should be }
|
57
|
-
end
|
58
|
-
|
59
|
-
context "destroy" do
|
60
|
-
subject { deploy_keys.destroy key_name }
|
61
|
-
before do
|
62
|
-
mock_deploy_keys
|
63
|
-
mock_delete_deploy_key
|
64
|
-
end
|
65
|
-
|
66
|
-
it { should have(1).item }
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "(hooks)" do
|
71
|
-
let(:url) { 'url' }
|
72
|
-
let(:token) { 'token' }
|
73
|
-
let(:hooks) { gitlab.hooks(repo) }
|
74
|
-
|
75
|
-
context "all" do
|
76
|
-
subject { hooks.all }
|
77
|
-
before { mock_hooks }
|
78
|
-
it { should have(1).item }
|
79
|
-
end
|
80
|
-
|
81
|
-
context "create" do
|
82
|
-
subject { hooks.create url, token }
|
83
|
-
before { mock_add_hook }
|
84
|
-
it { should be }
|
85
|
-
end
|
86
|
-
|
87
|
-
context "destroy" do
|
88
|
-
let(:mask) { "http://example.com" }
|
89
|
-
subject { hooks.destroy mask }
|
90
|
-
before do
|
91
|
-
mock_hooks
|
92
|
-
mock_remove_hook
|
93
|
-
end
|
94
|
-
it { should have(1).item }
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
context "(files)" do
|
99
|
-
let(:sha) { 'sha' }
|
100
|
-
let(:path) { 'path' }
|
101
|
-
|
102
|
-
context "get" do
|
103
|
-
subject { gitlab.files(repo).get sha, path }
|
104
|
-
|
105
|
-
context "success" do
|
106
|
-
before { mock_get_file }
|
107
|
-
it { should eq 'content' }
|
108
|
-
end
|
109
|
-
|
110
|
-
context "not found" do
|
111
|
-
before { mock_get_file_not_found }
|
112
|
-
it { should be_nil }
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|