livebuzz-gitx 0.1.1 → 0.1.2

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.
@@ -1,149 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://api.github.com/repos/livebuzzevents/livebuzz-gitx/pulls?head=livebuzz:feature-branch&state=open
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - application/vnd.github.v3+json
12
- User-Agent:
13
- - Octokit Ruby Gem 3.2.0
14
- Authorization:
15
- - token 123123
16
- Accept-Encoding:
17
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Server:
24
- - GitHub.com
25
- Date:
26
- - Tue, 05 Aug 2014 16:36:03 GMT
27
- Content-Type:
28
- - application/json; charset=utf-8
29
- Status:
30
- - 200 OK
31
- X-Ratelimit-Limit:
32
- - '5000'
33
- X-Ratelimit-Remaining:
34
- - '4991'
35
- X-Ratelimit-Reset:
36
- - '1407257585'
37
- Cache-Control:
38
- - private, max-age=60, s-maxage=60
39
- Etag:
40
- - '"6d00d48abf2adf1877c8244700cd4c6f"'
41
- X-Oauth-Scopes:
42
- - repo
43
- X-Accepted-Oauth-Scopes:
44
- - ''
45
- Vary:
46
- - Accept, Authorization, Cookie, X-GitHub-OTP
47
- - Accept-Encoding
48
- X-Github-Media-Type:
49
- - github.v3; format=json
50
- Link:
51
- - <https://api.github.com/repositories/17608725/pulls?head=livebuzz%3Afeature-branch&state=open&page=0>;
52
- rel="last"
53
- X-Xss-Protection:
54
- - 1; mode=block
55
- X-Frame-Options:
56
- - deny
57
- Content-Security-Policy:
58
- - default-src 'none'
59
- Content-Length:
60
- - '2'
61
- Access-Control-Allow-Credentials:
62
- - 'true'
63
- Access-Control-Expose-Headers:
64
- - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
65
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
66
- Access-Control-Allow-Origin:
67
- - "*"
68
- X-Github-Request-Id:
69
- - 46C5E25C:1E4F:1642AD9:53E107F3
70
- Strict-Transport-Security:
71
- - max-age=31536000; includeSubdomains
72
- X-Content-Type-Options:
73
- - nosniff
74
- X-Served-By:
75
- - d818ddef80f4c7d10683dd483558952a
76
- body:
77
- encoding: UTF-8
78
- string: '[{"html_url":"https://path/to/html/pull/request","issue_url":"https://api/path/to/issue/url","number":10,"head":{"ref":"branch_name"}}]'
79
- http_version:
80
- recorded_at: Tue, 05 Aug 2014 16:36:03 GMT
81
- - request:
82
- method: get
83
- uri: https://api.github.com/repos/livebuzzevents/livebuzz-gitx/commits/feature-branch/status
84
- body:
85
- encoding: US-ASCII
86
- string: ''
87
- headers:
88
- Accept:
89
- - application/vnd.github.v3+json
90
- User-Agent:
91
- - Octokit Ruby Gem 3.4.0
92
- Content-Type:
93
- - application/json
94
- Authorization:
95
- - token 123123
96
- Accept-Encoding:
97
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
98
- response:
99
- status:
100
- code: 200
101
- message: OK
102
- headers:
103
- Server:
104
- - GitHub.com
105
- Date:
106
- - Wed, 10 Dec 2014 19:01:27 GMT
107
- Content-Type:
108
- - application/json; charset=utf-8
109
- Transfer-Encoding:
110
- - chunked
111
- Status:
112
- - 200 OK
113
- X-Ratelimit-Limit:
114
- - '5000'
115
- X-Ratelimit-Remaining:
116
- - '4993'
117
- X-Ratelimit-Reset:
118
- - '1418241620'
119
- X-Oauth-Scopes:
120
- - repo
121
- X-Accepted-Oauth-Scopes:
122
- - repo, repo:status
123
- X-Github-Media-Type:
124
- - github.v3; format=json
125
- X-Xss-Protection:
126
- - 1; mode=block
127
- X-Frame-Options:
128
- - deny
129
- Content-Security-Policy:
130
- - default-src 'none'
131
- Access-Control-Allow-Credentials:
132
- - 'true'
133
- Access-Control-Expose-Headers:
134
- - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
135
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
136
- Access-Control-Allow-Origin:
137
- - "*"
138
- X-Github-Request-Id:
139
- - C6CBAFAF:141D:2F27072:54889887
140
- Strict-Transport-Security:
141
- - max-age=31536000; includeSubdomains; preload
142
- X-Content-Type-Options:
143
- - nosniff
144
- body:
145
- encoding: UTF-8
146
- string: '{"state":"success"}'
147
- http_version:
148
- recorded_at: Wed, 10 Dec 2014 19:14:11 GMT
149
- recorded_with: VCR 2.9.2
@@ -1,133 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://api.github.com/repos/livebuzzevents/livebuzz-gitx/pulls?head=livebuzz:feature-branch&state=open
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - application/vnd.github.v3+json
12
- User-Agent:
13
- - Octokit Ruby Gem 3.2.0
14
- Authorization:
15
- - token 123123
16
- Accept-Encoding:
17
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Server:
24
- - GitHub.com
25
- Date:
26
- - Tue, 05 Aug 2014 17:14:02 GMT
27
- Content-Type:
28
- - application/json; charset=utf-8
29
- Status:
30
- - 401 Unauthorized
31
- X-Github-Media-Type:
32
- - github.v3; format=json
33
- X-Ratelimit-Limit:
34
- - '60'
35
- X-Ratelimit-Remaining:
36
- - '59'
37
- X-Ratelimit-Reset:
38
- - '1407262442'
39
- X-Xss-Protection:
40
- - 1; mode=block
41
- X-Frame-Options:
42
- - deny
43
- Content-Security-Policy:
44
- - default-src 'none'
45
- Content-Length:
46
- - '83'
47
- Access-Control-Allow-Credentials:
48
- - 'true'
49
- Access-Control-Expose-Headers:
50
- - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
51
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
52
- Access-Control-Allow-Origin:
53
- - "*"
54
- X-Github-Request-Id:
55
- - 46C5E25C:552F:1BC5411:53E110DA
56
- Strict-Transport-Security:
57
- - max-age=31536000; includeSubdomains
58
- X-Content-Type-Options:
59
- - nosniff
60
- body:
61
- encoding: UTF-8
62
- string: '[]'
63
- http_version:
64
- recorded_at: Tue, 05 Aug 2014 17:14:02 GMT
65
- - request:
66
- method: get
67
- uri: https://api.github.com/repos/livebuzzevents/livebuzz-gitx/commits/feature-branch/status
68
- body:
69
- encoding: US-ASCII
70
- string: ''
71
- headers:
72
- Accept:
73
- - application/vnd.github.v3+json
74
- User-Agent:
75
- - Octokit Ruby Gem 3.4.0
76
- Content-Type:
77
- - application/json
78
- Authorization:
79
- - token 123123
80
- Accept-Encoding:
81
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
82
- response:
83
- status:
84
- code: 200
85
- message: OK
86
- headers:
87
- Server:
88
- - GitHub.com
89
- Date:
90
- - Wed, 10 Dec 2014 19:01:27 GMT
91
- Content-Type:
92
- - application/json; charset=utf-8
93
- Transfer-Encoding:
94
- - chunked
95
- Status:
96
- - 200 OK
97
- X-Ratelimit-Limit:
98
- - '5000'
99
- X-Ratelimit-Remaining:
100
- - '4993'
101
- X-Ratelimit-Reset:
102
- - '1418241620'
103
- X-Oauth-Scopes:
104
- - repo
105
- X-Accepted-Oauth-Scopes:
106
- - repo, repo:status
107
- X-Github-Media-Type:
108
- - github.v3; format=json
109
- X-Xss-Protection:
110
- - 1; mode=block
111
- X-Frame-Options:
112
- - deny
113
- Content-Security-Policy:
114
- - default-src 'none'
115
- Access-Control-Allow-Credentials:
116
- - 'true'
117
- Access-Control-Expose-Headers:
118
- - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
119
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
120
- Access-Control-Allow-Origin:
121
- - "*"
122
- X-Github-Request-Id:
123
- - C6CBAFAF:141D:2F27072:54889887
124
- Strict-Transport-Security:
125
- - max-age=31536000; includeSubdomains; preload
126
- X-Content-Type-Options:
127
- - nosniff
128
- body:
129
- encoding: UTF-8
130
- string: '{"state":"pending"}'
131
- http_version:
132
- recorded_at: Wed, 10 Dec 2014 19:14:11 GMT
133
- recorded_with: VCR 2.9.2
@@ -1,307 +0,0 @@
1
- require 'spec_helper'
2
- require 'livebuzz/gitx/cli/review_command'
3
-
4
- describe LiveBuzz::Gitx::Cli::ReviewCommand do
5
- let(:args) { [] }
6
- let(:options) { {} }
7
- let(:config) do
8
- {
9
- pretend: true
10
- }
11
- end
12
- let(:cli) { described_class.new(args, options, config) }
13
- let(:repo) { double('fake repo', config: repo_config) }
14
- let(:repo_config) do
15
- {
16
- 'remote.origin.url' => 'https://github.com/livebuzzevents/livebuzz-gitx'
17
- }
18
- end
19
- let(:branch) { double('fake branch', name: 'feature-branch') }
20
-
21
- before do
22
- allow(cli).to receive(:repo).and_return(repo)
23
- allow(cli).to receive(:current_branch).and_return(branch)
24
- allow(cli).to receive(:ask_editor).and_return('description')
25
- end
26
-
27
- describe '#review' do
28
- context 'when pull request does not exist' do
29
- let(:authorization_token) { '123123' }
30
- let(:changelog) { '* made some fixes' }
31
- let(:fake_update_command) { double('fake update command', update: nil) }
32
- let(:new_pull_request) do
33
- {
34
- html_url: "https://path/to/html/pull/request",
35
- issue_url: "https://api/path/to/issue/url",
36
- number: 10,
37
- head: {
38
- ref: "branch_name"
39
- }
40
- }
41
- end
42
- before do
43
- expect(LiveBuzz::Gitx::Cli::UpdateCommand).to receive(:new).and_return(fake_update_command)
44
-
45
- allow(cli).to receive(:authorization_token).and_return(authorization_token)
46
- expect(cli).to receive(:run_cmd).with("git log master...feature-branch --reverse --no-merges --pretty=format:'* %s%n%b'").and_return("* old commit\n\n* new commit").ordered
47
- expect(cli).to receive(:ask_editor).with("### Changelog\n* old commit\n\n* new commit\n#{LiveBuzz::Gitx::Github::PULL_REQUEST_FOOTER}", anything).and_return('description')
48
-
49
- stub_request(:post, 'https://api.github.com/repos/livebuzzevents/livebuzz-gitx/pulls').to_return(:status => 201, :body => new_pull_request.to_json, :headers => {'Content-Type' => 'application/json'})
50
-
51
- VCR.use_cassette('pull_request_does_not_exist') do
52
- cli.review
53
- end
54
- end
55
- it 'creates github pull request' do
56
- should meet_expectations
57
- end
58
- it 'runs expected commands' do
59
- should meet_expectations
60
- end
61
- end
62
- context 'when authorization_token is missing' do
63
- let(:authorization_token) { nil }
64
- it do
65
- allow(cli).to receive(:authorization_token).and_return(authorization_token)
66
- expect { cli.review }.to raise_error(/token not found/)
67
- end
68
- end
69
- context 'when pull request already exists' do
70
- let(:authorization_token) { '123123' }
71
- before do
72
- allow(cli).to receive(:authorization_token).and_return(authorization_token)
73
- expect(cli).to_not receive(:create_pull_request)
74
-
75
- VCR.use_cassette('pull_request_does_exist_with_success_status') do
76
- cli.review
77
- end
78
- end
79
- it 'does not create new pull request' do
80
- should meet_expectations
81
- end
82
- end
83
- context 'when --assignee option passed' do
84
- let(:options) do
85
- {
86
- assignee: 'johndoe'
87
- }
88
- end
89
- let(:authorization_token) { '123123' }
90
- before do
91
- allow(cli).to receive(:authorization_token).and_return(authorization_token)
92
-
93
- stub_request(:patch, /.*api.github.com.*/).to_return(:status => 200)
94
-
95
- VCR.use_cassette('pull_request_does_exist_with_success_status') do
96
- cli.review
97
- end
98
- end
99
- it 'updates github pull request' do
100
- expect(WebMock).to have_requested(:patch, "https://api.github.com/repos/livebuzzevents/livebuzz-gitx/issues/10")
101
- end
102
- end
103
- context 'when --open flag passed' do
104
- let(:options) do
105
- {
106
- open: true
107
- }
108
- end
109
- let(:authorization_token) { '123123' }
110
- before do
111
- allow(cli).to receive(:authorization_token).and_return(authorization_token)
112
- expect(cli).to receive(:run_cmd).with("open https://path/to/html/pull/request").ordered
113
- VCR.use_cassette('pull_request_does_exist_with_success_status') do
114
- cli.review
115
- end
116
- end
117
- it 'runs open command with pull request url' do
118
- should meet_expectations
119
- end
120
- end
121
- context 'when --bump flag is passed' do
122
- let(:options) do
123
- {
124
- bump: true
125
- }
126
- end
127
- let(:authorization_token) { '123123' }
128
- let(:reference) { double('fake reference', target_id: 'e12da4') }
129
- before do
130
- allow(cli).to receive(:authorization_token).and_return(authorization_token)
131
- expect(cli).to receive(:ask_editor).and_return('comment description')
132
- allow(repo).to receive(:head).and_return(reference)
133
- stub_request(:post, /.*api.github.com.*/).to_return(:status => 201)
134
-
135
- VCR.use_cassette('pull_request_does_exist_with_success_status') do
136
- cli.review
137
- end
138
- end
139
- it 'posts comment to github' do
140
- expect(WebMock).to have_requested(:post, "https://api.github.com/repos/livebuzzevents/livebuzz-gitx/issues/10/comments").
141
- with(body: {body: "[gitx] review bump :tada:\n\ncomment description"})
142
- end
143
- it 'creates pending build status for latest commit' do
144
- expect(WebMock).to have_requested(:post, 'https://api.github.com/repos/livebuzzevents/livebuzz-gitx/statuses/e12da4').
145
- with(body: {state: 'pending', context: 'peer_review', description: 'Peer review in progress'})
146
- end
147
- end
148
- context 'when --reject flag is passed' do
149
- let(:options) do
150
- {
151
- reject: true
152
- }
153
- end
154
- let(:authorization_token) { '123123' }
155
- let(:reference) { double('fake reference', target_id: 'e12da4') }
156
- before do
157
- allow(cli).to receive(:authorization_token).and_return(authorization_token)
158
- expect(cli).to receive(:ask_editor).and_return('comment body')
159
- allow(repo).to receive(:head).and_return(reference)
160
- stub_request(:post, /.*api.github.com.*/).to_return(:status => 201)
161
-
162
- VCR.use_cassette('pull_request_does_exist_with_success_status') do
163
- cli.review
164
- end
165
- end
166
- it 'posts comment to github' do
167
- expect(WebMock).to have_requested(:post, "https://api.github.com/repos/livebuzzevents/livebuzz-gitx/issues/10/comments").
168
- with(body: {body: "[gitx] review rejected\n\ncomment body"})
169
- end
170
- it 'creates failure build status for latest commit' do
171
- expect(WebMock).to have_requested(:post, 'https://api.github.com/repos/livebuzzevents/livebuzz-gitx/statuses/e12da4').
172
- with(body: {state: 'failure', context: 'peer_review', description: 'Peer review rejected'})
173
- end
174
- end
175
- context 'when --approve flag is passed' do
176
- let(:options) do
177
- {
178
- approve: true
179
- }
180
- end
181
- let(:authorization_token) { '123123' }
182
- let(:reference) { double('fake reference', target_id: 'e12da4') }
183
- before do
184
- allow(cli).to receive(:authorization_token).and_return(authorization_token)
185
- expect(cli).to receive(:ask_editor).and_return('comment body')
186
- allow(repo).to receive(:head).and_return(reference)
187
- stub_request(:post, /.*api.github.com.*/).to_return(:status => 201)
188
-
189
- VCR.use_cassette('pull_request_does_exist_with_success_status') do
190
- cli.review
191
- end
192
- end
193
- it 'posts comment to github' do
194
- expect(WebMock).to have_requested(:post, "https://api.github.com/repos/livebuzzevents/livebuzz-gitx/issues/10/comments").
195
- with(body: {body: "[gitx] review approved :shipit:\n\ncomment body"})
196
- end
197
- it 'creates success build status for latest commit' do
198
- expect(WebMock).to have_requested(:post, 'https://api.github.com/repos/livebuzzevents/livebuzz-gitx/statuses/e12da4').
199
- with(body: {state: 'success', context: 'peer_review', description: 'Peer review approved'})
200
- end
201
- end
202
- end
203
-
204
- describe '#authorization_token' do
205
- context 'when github.user is not configured' do
206
- it 'raises error' do
207
- expect do
208
- cli.send(:authorization_token)
209
- end.to raise_error(/Github user not configured/)
210
- end
211
- end
212
- context 'when global config token is nil' do
213
- let(:repo_config) do
214
- {
215
- 'remote.origin.url' => 'https://github.com/livebuzzevents/livebuzz-gitx',
216
- 'github.user' => 'ryan@codecrate.com'
217
- }
218
- end
219
- let(:github_password) { 'secretz' }
220
- let(:authorization_token) { '123981239123' }
221
- before do
222
- stub_request(:post, "https://ryan@codecrate.com:secretz@api.github.com/authorizations").
223
- to_return(:status => 200, :body => JSON.dump(token: authorization_token), :headers => {'Content-Type' => 'application/json'})
224
-
225
- expect(cli).to receive(:ask).with('Github password for ryan@codecrate.com: ', {:echo => false}).and_return(github_password)
226
- expect(cli).to receive(:ask).with('Github two factor authorization token (if enabled): ', {:echo => false}).and_return(nil)
227
-
228
- @auth_token = cli.send(:authorization_token)
229
- end
230
- it 'stores authorization_token in global config' do
231
- expect(global_config).to include('token' => authorization_token)
232
- end
233
- it { expect(@auth_token).to eq authorization_token }
234
- end
235
- context 'when global authorization_token is nil and first request fails' do
236
- let(:repo_config) do
237
- {
238
- 'remote.origin.url' => 'https://github.com/livebuzzevents/livebuzz-gitx',
239
- 'github.user' => 'ryan@codecrate.com'
240
- }
241
- end
242
- let(:github_password) { 'secretz' }
243
- let(:authorization_token) { '123981239123' }
244
- before do
245
- stub_request(:post, "https://ryan@codecrate.com:secretz@api.github.com/authorizations").
246
- to_return(:status => 401, :body => JSON.dump(token: authorization_token), :headers => {'Content-Type' => 'application/json'}).
247
- then.
248
- to_return(:status => 200, :body => JSON.dump(token: authorization_token), :headers => {'Content-Type' => 'application/json'})
249
-
250
- expect(cli).to receive(:ask).with('Github password for ryan@codecrate.com: ', {:echo => false}).and_return(github_password).twice
251
- expect(cli).to receive(:ask).with('Github two factor authorization token (if enabled): ', {:echo => false}).and_return(nil).twice
252
-
253
- @auth_token = cli.send(:authorization_token)
254
- end
255
- it 'stores authorization_token in global config' do
256
- expect(global_config).to include('token' => authorization_token)
257
- end
258
- it { expect(@auth_token).to eq authorization_token }
259
- end
260
- context 'when the global config has an existing token' do
261
- let(:authorization_token) { '123981239123' }
262
- let(:repo_config) do
263
- {
264
- 'remote.origin.url' => 'https://github.com/livebuzzevents/livebuzz-gitx',
265
- 'github.user' => 'ryan@codecrate.com'
266
- }
267
- end
268
- let(:config) do
269
- {
270
- 'token' => authorization_token
271
- }
272
- end
273
- before do
274
- File.open(global_config_file, 'w') do |file|
275
- file.write(config.to_yaml)
276
- end
277
- @auth_token = cli.send(:authorization_token)
278
- end
279
- it { expect(@auth_token).to eq authorization_token }
280
- end
281
- context 'when two factor authorization token given' do
282
- let(:repo_config) do
283
- {
284
- 'remote.origin.url' => 'https://github.com/livebuzzevents/livebuzz-gitx',
285
- 'github.user' => 'ryan@codecrate.com'
286
- }
287
- end
288
- let(:github_password) { 'secretz' }
289
- let(:authorization_token) { '123981239123' }
290
- let(:two_factor_auth_token) { '456456' }
291
- before do
292
- stub_request(:post, "https://ryan@codecrate.com:secretz@api.github.com/authorizations").
293
- with(headers: {'X-GitHub-OTP' => two_factor_auth_token}).
294
- to_return(:status => 200, :body => JSON.dump(token: authorization_token), :headers => {'Content-Type' => 'application/json'})
295
-
296
- expect(cli).to receive(:ask).with('Github password for ryan@codecrate.com: ', {:echo => false}).and_return(github_password)
297
- expect(cli).to receive(:ask).with('Github two factor authorization token (if enabled): ', {:echo => false}).and_return(two_factor_auth_token)
298
-
299
- @auth_token = cli.send(:authorization_token)
300
- end
301
- it 'stores authorization_token in global config' do
302
- expect(global_config).to include('token' => authorization_token)
303
- end
304
- it { expect(@auth_token).to eq authorization_token }
305
- end
306
- end
307
- end
data/spec/support/vcr.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'vcr'
2
-
3
- VCR.configure do |c|
4
- c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
5
- c.hook_into :webmock
6
- end