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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vx/service_connector/base.rb +3 -4
  3. data/lib/vx/service_connector/github/payload.rb +73 -38
  4. data/lib/vx/service_connector/github.rb +6 -6
  5. data/lib/vx/service_connector/{gitlab_v4 → gitlab_v5}/files.rb +1 -1
  6. data/lib/vx/service_connector/{gitlab_v4 → gitlab_v5}/hooks.rb +1 -1
  7. data/lib/vx/service_connector/{gitlab_v4 → gitlab_v5}/notices.rb +1 -1
  8. data/lib/vx/service_connector/gitlab_v5/payload.rb +112 -0
  9. data/lib/vx/service_connector/{gitlab_v4 → gitlab_v5}/repos.rb +1 -1
  10. data/lib/vx/service_connector/{gitlab_v4 → gitlab_v5}/session.rb +1 -1
  11. data/lib/vx/service_connector/gitlab_v5.rb +30 -2
  12. data/lib/vx/service_connector/model.rb +12 -20
  13. data/lib/vx/service_connector/version.rb +1 -1
  14. data/lib/vx/service_connector.rb +0 -19
  15. data/spec/fixtures/github/payload/foreign_pull_request.json +810 -1
  16. data/spec/fixtures/github/payload/pull_request.json +0 -1
  17. data/spec/fixtures/github/payload/push_tag.json +0 -1
  18. data/spec/fixtures/{gitlab_v4 → gitlab_v5}/commits.json +0 -0
  19. data/spec/fixtures/{gitlab_v4 → gitlab_v5}/hooks.json +0 -0
  20. data/spec/fixtures/gitlab_v5/payload/push.json +32 -0
  21. data/spec/fixtures/{gitlab_v4 → gitlab_v5}/projects.json +0 -0
  22. data/spec/fixtures/{gitlab_v4 → gitlab_v5}/user_keys.json +0 -0
  23. data/spec/lib/github_payload_spec.rb +43 -94
  24. data/spec/lib/github_spec.rb +0 -23
  25. data/spec/lib/gitlab_v5_payload_spec.rb +33 -0
  26. data/spec/lib/gitlab_v5_spec.rb +74 -0
  27. data/spec/lib/model_spec.rb +3 -28
  28. data/spec/lib/service_connector_spec.rb +0 -35
  29. data/spec/support/github_web_mocks.rb +2 -2
  30. data/spec/support/gitlab_v5_web_mocks.rb +41 -2
  31. metadata +20 -32
  32. data/lib/vx/service_connector/github/commits.rb +0 -33
  33. data/lib/vx/service_connector/gitlab_v4/commits.rb +0 -35
  34. data/lib/vx/service_connector/gitlab_v4/deploy_keys.rb +0 -32
  35. data/lib/vx/service_connector/gitlab_v4/payload.rb +0 -126
  36. data/lib/vx/service_connector/gitlab_v4.rb +0 -49
  37. data/spec/fixtures/gitlab_v4/payload/merge_request1_unchecked.json +0 -47
  38. data/spec/fixtures/gitlab_v4/payload/merge_request2_can_be_merge.json +0 -47
  39. data/spec/fixtures/gitlab_v4/payload/push.json +0 -106
  40. data/spec/lib/gitlab_v4_payload_spec.rb +0 -101
  41. data/spec/lib/gitlab_v4_spec.rb +0 -141
  42. data/spec/support/gitlab_v4_web_mocks.rb +0 -73
@@ -1,141 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Vx::ServiceConnector::GitlabV4 do
4
-
5
- include GitlabV4WebMocks
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_user_keys }
50
- it { should have(1).item }
51
- end
52
-
53
- context "create" do
54
- subject { deploy_keys.create key_name, public_key }
55
- before { mock_add_user_key }
56
- it { should be }
57
- end
58
-
59
- context "destroy" do
60
- subject { deploy_keys.destroy key_name }
61
-
62
- before do
63
- mock_user_keys
64
- mock_delete_user_key
65
- end
66
-
67
- it { should have(1).item }
68
- end
69
- end
70
-
71
- context "(hooks)" do
72
- let(:url) { 'url' }
73
- let(:token) { 'token' }
74
- let(:hooks) { gitlab.hooks(repo) }
75
-
76
- context "all" do
77
- subject { hooks.all }
78
- before { mock_hooks }
79
- it { should have(1).item }
80
- end
81
-
82
- context "create" do
83
- subject { hooks.create url, token }
84
- before { mock_add_hook }
85
- it { should be }
86
- end
87
-
88
- context "destroy" do
89
- let(:mask) { "http://example.com" }
90
- subject { hooks.destroy mask }
91
- before do
92
- mock_hooks
93
- mock_remove_hook
94
- end
95
- it { should have(1).item }
96
- end
97
- end
98
-
99
- context "(files)" do
100
- let(:sha) { 'sha' }
101
- let(:path) { 'path' }
102
-
103
- context "get" do
104
- subject { gitlab.files(repo).get sha, path }
105
-
106
- context "success" do
107
- before { mock_get_file }
108
- it { should eq 'content' }
109
- end
110
-
111
- context "not found" do
112
- before { mock_get_file_not_found }
113
- it { should be_nil }
114
- end
115
- end
116
- end
117
-
118
- context "(commits)" do
119
- let(:sha) { 'sha' }
120
-
121
- context "get" do
122
- subject { gitlab.commits(repo).get sha }
123
-
124
- context "success" do
125
- before { mock_get_commit }
126
- it { should be }
127
- its(:sha) { should eq 'ed899a2f4b50b4370feeea94676502b42383c746' }
128
- its(:message) { should eq 'Replace sanitize with escape once' }
129
- its(:author) { should eq 'Dmitriy Zaporozhets' }
130
- its(:author_email) { should eq 'dzaporozhets@sphereconsultinginc.com' }
131
- its(:http_url) { should be_nil }
132
- end
133
-
134
- context "not found" do
135
- before { mock_get_commit_not_found }
136
- it { should be_nil }
137
- end
138
- end
139
- end
140
-
141
- end
@@ -1,73 +0,0 @@
1
- module GitlabV4WebMocks
2
-
3
- def mock_repos
4
- mock_get "projects", 'projects'
5
- end
6
-
7
- def mock_user_keys
8
- mock_get "user/keys", 'user_keys'
9
- end
10
-
11
- def mock_add_user_key
12
- mock_post "user/keys", "{\"title\":\"me@example.com for full/name\",\"key\":\"public key\"}"
13
- end
14
-
15
- def mock_delete_user_key
16
- mock_delete "user/keys/589", 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
26
-
27
- def mock_hooks
28
- mock_get "projects/1/hooks", 'hooks'
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
44
- mock_get "projects/1/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
52
-
53
- def mock_get(url, fixture)
54
- stub_request(:get, "http://example.com/api/v3/#{url}").
55
- with(:headers => {'Accept'=>'application/json', 'PRIVATE-TOKEN' => "token"}).
56
- to_return(
57
- :status => 200,
58
- :body => read_fixture("gitlab_v4/#{fixture}.json"),
59
- :headers => {'Content-Type' => 'application/json'})
60
- end
61
-
62
- def mock_post(url, body)
63
- stub_request(:post, "http://example.com/api/v3/#{url}").
64
- with(:headers => {'Accept'=>'application/json', }, body: body).
65
- to_return(:status => 200, :body => "{}", :headers => {'Content-Type' => 'application/json'})
66
- end
67
-
68
- def mock_delete(url, body)
69
- stub_request(:delete, "http://example.com/api/v3/#{url}").
70
- with(:headers => {'Accept'=>'application/json', }, body: body).
71
- to_return(:status => 200, :body => "{}", :headers => {'Content-Type' => 'application/json'})
72
- end
73
- end