vx-service_connector 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +10 -0
- data/lib/vx/service_connector.rb +37 -0
- data/lib/vx/service_connector/base.rb +27 -0
- data/lib/vx/service_connector/github.rb +49 -0
- data/lib/vx/service_connector/github/commits.rb +33 -0
- data/lib/vx/service_connector/github/deploy_keys.rb +29 -0
- data/lib/vx/service_connector/github/files.rb +21 -0
- data/lib/vx/service_connector/github/hooks.rb +33 -0
- data/lib/vx/service_connector/github/notices.rb +40 -0
- data/lib/vx/service_connector/github/payload.rb +124 -0
- data/lib/vx/service_connector/github/repos.rb +52 -0
- data/lib/vx/service_connector/gitlab_v3.rb +29 -0
- data/lib/vx/service_connector/gitlab_v3/deploy_keys.rb +20 -0
- data/lib/vx/service_connector/gitlab_v3/repos.rb +28 -0
- data/lib/vx/service_connector/model.rb +82 -0
- data/lib/vx/service_connector/version.rb +5 -0
- data/spec/fixtures/github/add_deploy_key.json +6 -0
- data/spec/fixtures/github/commit.json +83 -0
- data/spec/fixtures/github/create_hook.json +12 -0
- data/spec/fixtures/github/create_status.json +5 -0
- data/spec/fixtures/github/deploy_keys.json +8 -0
- data/spec/fixtures/github/hooks.json +18 -0
- data/spec/fixtures/github/org_repos.json +51 -0
- data/spec/fixtures/github/orgs.json +8 -0
- data/spec/fixtures/github/payload/closed_pull_request.json +392 -0
- data/spec/fixtures/github/payload/foreign_pull_request.json +1 -0
- data/spec/fixtures/github/payload/pull_request.json +392 -0
- data/spec/fixtures/github/payload/push.json +92 -0
- data/spec/fixtures/github/payload/push_tag.json +135 -0
- data/spec/fixtures/github/user_repos.json +48 -0
- data/spec/fixtures/gitlab_v3/deploy_keys.json +14 -0
- data/spec/fixtures/gitlab_v3/projects.json +72 -0
- data/spec/lib/github_payload_spec.rb +136 -0
- data/spec/lib/github_spec.rb +159 -0
- data/spec/lib/gitlab_v3_spec.rb +44 -0
- data/spec/lib/model_spec.rb +37 -0
- data/spec/lib/service_connector_spec.rb +30 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/support/create.rb +6 -0
- data/spec/support/github_web_mocks.rb +101 -0
- data/spec/support/gitlab_v3_mocks.rb +29 -0
- data/spec/support/read_fixture.rb +12 -0
- data/vx-service_connector.gemspec +28 -0
- metadata +203 -0
@@ -0,0 +1,135 @@
|
|
1
|
+
{
|
2
|
+
"ref":"refs/tags/v0.0.1",
|
3
|
+
"after":"2d6e206be0b94c9694af0ad37a7bf44207500b9f",
|
4
|
+
"before":"0000000000000000000000000000000000000000",
|
5
|
+
"created":true,
|
6
|
+
"deleted":false,
|
7
|
+
"forced":true,
|
8
|
+
"compare":"https://github.com/evrone/serverist-sample_storage/compare/v0.0.1",
|
9
|
+
"commits":null,
|
10
|
+
"head_commit":{
|
11
|
+
"id":"c391528c6fd03cbf9bc74b8ac42e0a50d953eeea",
|
12
|
+
"distinct":true,
|
13
|
+
"message":"move redis methods to module Config, add static_sample_storage and dynamic_sample_storage to SampleStorage module",
|
14
|
+
"timestamp":"2013-12-04T06:55:04-08:00",
|
15
|
+
"url":"https://github.com/evrone/serverist-sample_storage/commit/c391528c6fd03cbf9bc74b8ac42e0a50d953eeea",
|
16
|
+
"author":{
|
17
|
+
"name":"Dmitry Galinsky",
|
18
|
+
"email":"dima.exe@gmail.com",
|
19
|
+
"username":"dima-exe"
|
20
|
+
},
|
21
|
+
"committer":{
|
22
|
+
"name":"Dmitry Galinsky",
|
23
|
+
"email":"dima.exe@gmail.com",
|
24
|
+
"username":"dima-exe"
|
25
|
+
},
|
26
|
+
"added":[
|
27
|
+
"lib/serverist/sample_storage/config.rb",
|
28
|
+
"spec/lib/config_spec.rb"
|
29
|
+
],
|
30
|
+
"removed":null,
|
31
|
+
"modified":[
|
32
|
+
"lib/serverist/sample_storage.rb",
|
33
|
+
"lib/serverist/sample_storage/redis.rb",
|
34
|
+
"spec/lib/sample_storage_spec.rb",
|
35
|
+
"spec/spec_helper.rb"
|
36
|
+
]
|
37
|
+
},
|
38
|
+
"repository":{
|
39
|
+
"id":14926202,
|
40
|
+
"name":"serverist-sample_storage",
|
41
|
+
"url":"https://github.com/evrone/serverist-sample_storage",
|
42
|
+
"description":"",
|
43
|
+
"watchers":0,
|
44
|
+
"stargazers":0,
|
45
|
+
"forks":0,
|
46
|
+
"fork":false,
|
47
|
+
"size":84,
|
48
|
+
"owner":{
|
49
|
+
"name":"evrone",
|
50
|
+
"email":"oleg@evrone.com"
|
51
|
+
},
|
52
|
+
"private":false,
|
53
|
+
"open_issues":0,
|
54
|
+
"has_issues":true,
|
55
|
+
"has_downloads":true,
|
56
|
+
"has_wiki":true,
|
57
|
+
"language":"Ruby",
|
58
|
+
"created_at":1386167861,
|
59
|
+
"pushed_at":1386168924,
|
60
|
+
"master_branch":"master",
|
61
|
+
"organization":"evrone"
|
62
|
+
},
|
63
|
+
"pusher":{
|
64
|
+
"name":"dima-exe",
|
65
|
+
"email":"dima.exe@gmail.com"
|
66
|
+
},
|
67
|
+
"token":"4328934d-7c7a-4f44-b731-605d83d9ba40",
|
68
|
+
"repo_callback":{
|
69
|
+
"ref":"refs/tags/v0.0.1",
|
70
|
+
"after":"2d6e206be0b94c9694af0ad37a7bf44207500b9f",
|
71
|
+
"before":"0000000000000000000000000000000000000000",
|
72
|
+
"created":true,
|
73
|
+
"deleted":false,
|
74
|
+
"forced":true,
|
75
|
+
"compare":"https://github.com/evrone/serverist-sample_storage/compare/v0.0.1",
|
76
|
+
"commits":null,
|
77
|
+
"head_commit":{
|
78
|
+
"id":"c391528c6fd03cbf9bc74b8ac42e0a50d953eeea",
|
79
|
+
"distinct":true,
|
80
|
+
"message":"move redis methods to module Config, add static_sample_storage and dynamic_sample_storage to SampleStorage module",
|
81
|
+
"timestamp":"2013-12-04T06:55:04-08:00",
|
82
|
+
"url":"https://github.com/evrone/serverist-sample_storage/commit/c391528c6fd03cbf9bc74b8ac42e0a50d953eeea",
|
83
|
+
"author":{
|
84
|
+
"name":"Dmitry Galinsky",
|
85
|
+
"email":"dima.exe@gmail.com",
|
86
|
+
"username":"dima-exe"
|
87
|
+
},
|
88
|
+
"committer":{
|
89
|
+
"name":"Dmitry Galinsky",
|
90
|
+
"email":"dima.exe@gmail.com",
|
91
|
+
"username":"dima-exe"
|
92
|
+
},
|
93
|
+
"added":[
|
94
|
+
"lib/serverist/sample_storage/config.rb",
|
95
|
+
"spec/lib/config_spec.rb"
|
96
|
+
],
|
97
|
+
"removed":null,
|
98
|
+
"modified":[
|
99
|
+
"lib/serverist/sample_storage.rb",
|
100
|
+
"lib/serverist/sample_storage/redis.rb",
|
101
|
+
"spec/lib/sample_storage_spec.rb",
|
102
|
+
"spec/spec_helper.rb"
|
103
|
+
]
|
104
|
+
},
|
105
|
+
"repository":{
|
106
|
+
"id":14926202,
|
107
|
+
"name":"serverist-sample_storage",
|
108
|
+
"url":"https://github.com/evrone/serverist-sample_storage",
|
109
|
+
"description":"",
|
110
|
+
"watchers":0,
|
111
|
+
"stargazers":0,
|
112
|
+
"forks":0,
|
113
|
+
"fork":false,
|
114
|
+
"size":84,
|
115
|
+
"owner":{
|
116
|
+
"name":"evrone",
|
117
|
+
"email":"oleg@evrone.com"
|
118
|
+
},
|
119
|
+
"private":false,
|
120
|
+
"open_issues":0,
|
121
|
+
"has_issues":true,
|
122
|
+
"has_downloads":true,
|
123
|
+
"has_wiki":true,
|
124
|
+
"language":"Ruby",
|
125
|
+
"created_at":1386167861,
|
126
|
+
"pushed_at":1386168924,
|
127
|
+
"master_branch":"master",
|
128
|
+
"organization":"evrone"
|
129
|
+
},
|
130
|
+
"pusher":{
|
131
|
+
"name":"dima-exe",
|
132
|
+
"email":"dima.exe@gmail.com"
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": 1296269,
|
4
|
+
"owner": {
|
5
|
+
"login": "octocat",
|
6
|
+
"id": 1,
|
7
|
+
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
8
|
+
"gravatar_id": "somehexcode",
|
9
|
+
"url": "https://api.github.com/users/octocat",
|
10
|
+
"html_url": "https://github.com/octocat",
|
11
|
+
"followers_url": "https://api.github.com/users/octocat/followers",
|
12
|
+
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
13
|
+
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
14
|
+
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
15
|
+
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
16
|
+
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
17
|
+
"repos_url": "https://api.github.com/users/octocat/repos",
|
18
|
+
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
19
|
+
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
20
|
+
"type": "User",
|
21
|
+
"site_admin": false
|
22
|
+
},
|
23
|
+
"name": "Hello-World",
|
24
|
+
"full_name": "octocat/user",
|
25
|
+
"description": "This your first repo!",
|
26
|
+
"private": false,
|
27
|
+
"fork": true,
|
28
|
+
"url": "https://api.github.com/repos/octocat/Hello-World",
|
29
|
+
"html_url": "https://github.com/octocat/Hello-World",
|
30
|
+
"clone_url": "https://github.com/octocat/Hello-World.git",
|
31
|
+
"git_url": "git://github.com/octocat/Hello-World.git",
|
32
|
+
"ssh_url": "git@github.com:octocat/Hello-World.git",
|
33
|
+
"svn_url": "https://svn.github.com/octocat/Hello-World",
|
34
|
+
"mirror_url": "git://git.example.com/octocat/Hello-World",
|
35
|
+
"homepage": "https://github.com",
|
36
|
+
"language": null,
|
37
|
+
"forks_count": 9,
|
38
|
+
"stargazers_count": 80,
|
39
|
+
"watchers_count": 80,
|
40
|
+
"size": 108,
|
41
|
+
"default_branch": "master",
|
42
|
+
"master_branch": "master",
|
43
|
+
"open_issues_count": 0,
|
44
|
+
"pushed_at": "2011-01-26T19:06:43Z",
|
45
|
+
"created_at": "2011-01-26T19:01:12Z",
|
46
|
+
"updated_at": "2011-01-26T19:14:43Z"
|
47
|
+
}
|
48
|
+
]
|
@@ -0,0 +1,14 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": 1,
|
4
|
+
"title" : "Public key",
|
5
|
+
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4 596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4 soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=",
|
6
|
+
"created_at":"2013-10-02T10:12:29Z"
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"id": 3,
|
10
|
+
"title" : "Another Public key",
|
11
|
+
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4 596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4 soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=",
|
12
|
+
"created_at":"2013-10-02T11:12:29Z"
|
13
|
+
}
|
14
|
+
]
|
@@ -0,0 +1,72 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": 4,
|
4
|
+
"description": "description",
|
5
|
+
"default_branch": "master",
|
6
|
+
"public": false,
|
7
|
+
"visibility_level": 0,
|
8
|
+
"ssh_url_to_repo": "git@example.com:diaspora/diaspora-client.git",
|
9
|
+
"http_url_to_repo": "http://example.com/diaspora/diaspora-client.git",
|
10
|
+
"web_url": "http://example.com/diaspora/diaspora-client",
|
11
|
+
"owner": {
|
12
|
+
"id": 3,
|
13
|
+
"name": "Diaspora",
|
14
|
+
"created_at": "2013-09-30T13: 46: 02Z"
|
15
|
+
},
|
16
|
+
"name": "Diaspora Client",
|
17
|
+
"name_with_namespace": "Diaspora / Diaspora Client",
|
18
|
+
"path": "diaspora-client",
|
19
|
+
"path_with_namespace": "diaspora/diaspora-client",
|
20
|
+
"issues_enabled": true,
|
21
|
+
"merge_requests_enabled": true,
|
22
|
+
"wall_enabled": false,
|
23
|
+
"wiki_enabled": true,
|
24
|
+
"snippets_enabled": false,
|
25
|
+
"created_at": "2013-09-30T13: 46: 02Z",
|
26
|
+
"last_activity_at": "2013-09-30T13: 46: 02Z",
|
27
|
+
"namespace": {
|
28
|
+
"created_at": "2013-09-30T13: 46: 02Z",
|
29
|
+
"description": "",
|
30
|
+
"id": 3,
|
31
|
+
"name": "Diaspora",
|
32
|
+
"owner_id": 1,
|
33
|
+
"path": "diaspora",
|
34
|
+
"updated_at": "2013-09-30T13: 46: 02Z"
|
35
|
+
}
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"id": 6,
|
39
|
+
"description": "description",
|
40
|
+
"default_branch": "master",
|
41
|
+
"public": false,
|
42
|
+
"visibility_level": 0,
|
43
|
+
"ssh_url_to_repo": "git@example.com:brightbox/puppet.git",
|
44
|
+
"http_url_to_repo": "http://example.com/brightbox/puppet.git",
|
45
|
+
"web_url": "http://example.com/brightbox/puppet",
|
46
|
+
"owner": {
|
47
|
+
"id": 4,
|
48
|
+
"name": "Brightbox",
|
49
|
+
"created_at": "2013-09-30T13:46:02Z"
|
50
|
+
},
|
51
|
+
"name": "Puppet",
|
52
|
+
"name_with_namespace": "Brightbox / Puppet",
|
53
|
+
"path": "puppet",
|
54
|
+
"path_with_namespace": "brightbox/puppet",
|
55
|
+
"issues_enabled": true,
|
56
|
+
"merge_requests_enabled": true,
|
57
|
+
"wall_enabled": false,
|
58
|
+
"wiki_enabled": true,
|
59
|
+
"snippets_enabled": false,
|
60
|
+
"created_at": "2013-09-30T13:46:02Z",
|
61
|
+
"last_activity_at": "2013-09-30T13:46:02Z",
|
62
|
+
"namespace": {
|
63
|
+
"created_at": "2013-09-30T13:46:02Z",
|
64
|
+
"description": "",
|
65
|
+
"id": 4,
|
66
|
+
"name": "Brightbox",
|
67
|
+
"owner_id": 1,
|
68
|
+
"path": "brightbox",
|
69
|
+
"updated_at": "2013-09-30T13:46:02Z"
|
70
|
+
}
|
71
|
+
}
|
72
|
+
]
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vx::ServiceConnector::Github::Payload do
|
4
|
+
let(:content) { read_json_fixture("github/payload/push") }
|
5
|
+
let(:payload) { described_class.new content }
|
6
|
+
subject { payload }
|
7
|
+
|
8
|
+
context "push" do
|
9
|
+
let(:url) { "https://github.com/evrone/ci-worker-test-repo/compare/b665f9023956...687753389908" }
|
10
|
+
|
11
|
+
its(:pull_request?) { should be_false }
|
12
|
+
its(:pull_request_number) { should be_nil }
|
13
|
+
its(:head) { should eq '84158c732ff1af3db9775a37a74ddc39f5c4078f' }
|
14
|
+
its(:base) { should eq 'b665f90239563c030f1b280a434b3d84daeda1bd' }
|
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("github/payload/pull_request") }
|
25
|
+
let(:url) { "https://api.github.com/repos/evrone/cybergifts/pulls/177" }
|
26
|
+
|
27
|
+
its(:pull_request?) { should be_true }
|
28
|
+
its(:pull_request_number) { should eq 177 }
|
29
|
+
its(:head) { should eq '84158c732ff1af3db9775a37a74ddc39f5c4078f' }
|
30
|
+
its(:base) { should eq 'a1ea1a6807ab8de87e0d685b7d5dcad0c081254e' }
|
31
|
+
its(:branch) { should eq 'test' }
|
32
|
+
its(:branch_label) { should eq 'dima-exe:test' }
|
33
|
+
its(:url) { should eq url }
|
34
|
+
|
35
|
+
its(:pull_request_head_repo_id){ should eq 7155123 }
|
36
|
+
its(:pull_request_base_repo_id){ should eq 7155123 }
|
37
|
+
end
|
38
|
+
|
39
|
+
context "tag?" do
|
40
|
+
let(:content) { read_json_fixture("github/payload/push_tag") }
|
41
|
+
subject { payload.tag? }
|
42
|
+
it { should be_true }
|
43
|
+
|
44
|
+
context "when regular push" do
|
45
|
+
let(:content) { read_json_fixture("github/payload/push") }
|
46
|
+
it { should be_false }
|
47
|
+
end
|
48
|
+
|
49
|
+
context "when pull request" do
|
50
|
+
let(:content) { read_json_fixture("github/payload/pull_request") }
|
51
|
+
it { should be_false }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "closed_pull_request?" do
|
56
|
+
subject { payload.closed_pull_request? }
|
57
|
+
context "when state is closed" do
|
58
|
+
let(:content) { read_json_fixture("github/payload/closed_pull_request") }
|
59
|
+
it { should be_true }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "foreign_pull_request?" do
|
64
|
+
subject { payload.foreign_pull_request? }
|
65
|
+
|
66
|
+
context "when same repo" do
|
67
|
+
let(:content) { read_json_fixture("github/payload/pull_request") }
|
68
|
+
it { should be_false }
|
69
|
+
end
|
70
|
+
|
71
|
+
context "when different repo" do
|
72
|
+
let(:content) { read_json_fixture("github/payload/foreign_pull_request") }
|
73
|
+
it { should be_true }
|
74
|
+
end
|
75
|
+
|
76
|
+
context "when is not pull request" do
|
77
|
+
it { should be_false }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "ignore?" do
|
82
|
+
subject { payload.ignore? }
|
83
|
+
|
84
|
+
context "when pull request" do
|
85
|
+
let(:content) { read_json_fixture("github/payload/foreign_pull_request") }
|
86
|
+
it { should be_false}
|
87
|
+
|
88
|
+
context "and is closed" do
|
89
|
+
before do
|
90
|
+
expect(payload).to receive(:closed_pull_request?) { true }
|
91
|
+
end
|
92
|
+
it { should be_true }
|
93
|
+
end
|
94
|
+
|
95
|
+
context "and same repo" do
|
96
|
+
let(:content) { read_json_fixture("github/payload/pull_request") }
|
97
|
+
it { should be_true }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context "when regular commit" do
|
102
|
+
it { should be_false }
|
103
|
+
|
104
|
+
context "and deleted branch" do
|
105
|
+
before do
|
106
|
+
expect(payload).to receive(:head) { '0000000000000000000000000000000000000000' }
|
107
|
+
end
|
108
|
+
it { should be_true }
|
109
|
+
end
|
110
|
+
|
111
|
+
context "and tag created" do
|
112
|
+
before do
|
113
|
+
expect(payload).to receive(:tag?) { true }
|
114
|
+
end
|
115
|
+
it { should be_true }
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context "to_model" do
|
121
|
+
subject { payload.to_model }
|
122
|
+
it { should be_instance_of(Vx::ServiceConnector::Model::Payload) }
|
123
|
+
|
124
|
+
its(:values) { should eq(
|
125
|
+
[false,
|
126
|
+
nil,
|
127
|
+
"84158c732ff1af3db9775a37a74ddc39f5c4078f",
|
128
|
+
"b665f90239563c030f1b280a434b3d84daeda1bd",
|
129
|
+
"master",
|
130
|
+
"master",
|
131
|
+
"https://github.com/evrone/ci-worker-test-repo/compare/b665f9023956...687753389908",
|
132
|
+
false]
|
133
|
+
) }
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vx::ServiceConnector::Github do
|
4
|
+
|
5
|
+
include GithubWebMocks
|
6
|
+
|
7
|
+
let(:login) { 'login' }
|
8
|
+
let(:token) { 'token' }
|
9
|
+
let(:repo) { create :repo }
|
10
|
+
let(:github) { described_class.new login, token }
|
11
|
+
|
12
|
+
subject { github }
|
13
|
+
|
14
|
+
it { should be }
|
15
|
+
|
16
|
+
context "(notices)" do
|
17
|
+
let(:notices) { github.notices(repo) }
|
18
|
+
|
19
|
+
context "create" do
|
20
|
+
let(:sha) { 'sha' }
|
21
|
+
let(:url) { 'url' }
|
22
|
+
let(:desc) { 'description' }
|
23
|
+
|
24
|
+
{ started: "pending", passed: "success", failed: "failure", errored: "error"}.each do |k,v|
|
25
|
+
context "#{k}" do
|
26
|
+
subject { notices.create sha, k, url, desc }
|
27
|
+
before { mock_create_notice(v) }
|
28
|
+
it { should be }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "(repos)" do
|
35
|
+
subject { github.repos }
|
36
|
+
|
37
|
+
before do
|
38
|
+
mock_user_repos
|
39
|
+
mock_org_repos
|
40
|
+
mock_orgs
|
41
|
+
end
|
42
|
+
|
43
|
+
it { should have(2).item }
|
44
|
+
|
45
|
+
context "values" do
|
46
|
+
subject { github.repos.map(&:values) }
|
47
|
+
it { should eq(
|
48
|
+
[[1296269, "octocat/user", false,
|
49
|
+
"git@github.com:octocat/Hello-World.git",
|
50
|
+
"https://github.com/octocat/Hello-World",
|
51
|
+
"This your first repo!"],
|
52
|
+
[1296269, "octocat/org", false,
|
53
|
+
"git@github.com:octocat/Hello-World.git",
|
54
|
+
"https://github.com/octocat/Hello-World",
|
55
|
+
"This your first repo!"]]
|
56
|
+
) }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "(deploy_keys)" do
|
61
|
+
let(:key_name) { 'octocat@octomac' }
|
62
|
+
let(:public_key) { 'public key' }
|
63
|
+
let(:deploy_keys) { github.deploy_keys(repo) }
|
64
|
+
|
65
|
+
context "all" do
|
66
|
+
subject { deploy_keys.all }
|
67
|
+
before { mock_deploy_keys }
|
68
|
+
it { should have(1).item }
|
69
|
+
end
|
70
|
+
|
71
|
+
context "create" do
|
72
|
+
subject { deploy_keys.create key_name, public_key }
|
73
|
+
before { mock_add_deploy_key }
|
74
|
+
it { should be }
|
75
|
+
end
|
76
|
+
|
77
|
+
context "destroy" do
|
78
|
+
subject { deploy_keys.destroy key_name}
|
79
|
+
|
80
|
+
before do
|
81
|
+
mock_deploy_keys
|
82
|
+
mock_delete_deploy_key
|
83
|
+
end
|
84
|
+
|
85
|
+
it { should have(1).item }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context "(hooks)" do
|
90
|
+
let(:url) { 'url' }
|
91
|
+
let(:token) { 'token' }
|
92
|
+
let(:hooks) { github.hooks(repo) }
|
93
|
+
|
94
|
+
context "all" do
|
95
|
+
subject { hooks.all }
|
96
|
+
before { mock_hooks }
|
97
|
+
it { should have(1).item }
|
98
|
+
end
|
99
|
+
|
100
|
+
context "create" do
|
101
|
+
subject { hooks.create url, token }
|
102
|
+
before { mock_add_hook }
|
103
|
+
it { should be }
|
104
|
+
end
|
105
|
+
|
106
|
+
context "destroy" do
|
107
|
+
let(:mask) { "http://example.com" }
|
108
|
+
subject { hooks.destroy mask }
|
109
|
+
before do
|
110
|
+
mock_hooks
|
111
|
+
mock_remove_hook
|
112
|
+
end
|
113
|
+
it { should have(1).item }
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context "(files)" do
|
118
|
+
let(:sha) { 'sha' }
|
119
|
+
let(:path) { 'path' }
|
120
|
+
|
121
|
+
context "get" do
|
122
|
+
subject { github.files(repo).get sha, path }
|
123
|
+
|
124
|
+
context "success" do
|
125
|
+
before { mock_get_file }
|
126
|
+
it { should eq 'content' }
|
127
|
+
end
|
128
|
+
|
129
|
+
context "not found" do
|
130
|
+
before { mock_get_file_not_found }
|
131
|
+
it { should be_nil }
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context "(commits)" do
|
137
|
+
let(:sha) { 'sha' }
|
138
|
+
|
139
|
+
context "get" do
|
140
|
+
subject { github.commits(repo).get sha }
|
141
|
+
|
142
|
+
context "success" do
|
143
|
+
before { mock_get_commit }
|
144
|
+
it { should be }
|
145
|
+
its(:sha) { should eq '6dcb09b5b57875f334f61aebed695e2e4193db5e' }
|
146
|
+
its(:message) { should eq 'Fix all the bugs' }
|
147
|
+
its(:author) { should eq 'Monalisa Octocat' }
|
148
|
+
its(:author_email) { should eq 'support@github.com' }
|
149
|
+
its(:http_url) { should be_nil }
|
150
|
+
end
|
151
|
+
|
152
|
+
context "not found" do
|
153
|
+
before { mock_get_commit_not_found }
|
154
|
+
it { should be_nil }
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|