gerry 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gerry/client/request.rb +3 -4
- data/lib/gerry/version.rb +1 -1
- data/spec/changes_spec.rb +30 -13
- data/spec/fixtures/changes_batch_0.json +18 -0
- data/spec/fixtures/changes_batch_1.json +17 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54504c142edb7bfbe2b9bcc7ad1c4e0d8e288ec0
|
4
|
+
data.tar.gz: 52bb964e310b1d57507e2443d6eb5170939ba2f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9edca037aead6cf979a3f331de2a7122fba12de1fd171517bbf439912223cf4c375bfe3d510ed9724acb5820745a15de91900ffba09130f7d6c02fd827e0cea
|
7
|
+
data.tar.gz: 01c5ca61b668906666d7599184aefeebfc7779192f172ecddd47eb51f5f08631a55831ca01264f84fbfc848fee2d68468469e172ac431f4bab581bb80c1dea62
|
data/lib/gerry/client/request.rb
CHANGED
@@ -33,14 +33,13 @@ module Gerry
|
|
33
33
|
end
|
34
34
|
|
35
35
|
result = parse(response)
|
36
|
-
unless result.is_a?(Array) && result.last.is_a?(Hash)
|
37
|
-
return result
|
38
|
-
end
|
36
|
+
return result unless result.is_a?(Array) && result.last.is_a?(Hash)
|
39
37
|
|
40
38
|
all_results.concat(result)
|
39
|
+
return all_results unless result.last.delete('_more_changes')
|
41
40
|
|
42
41
|
# Append the start parameter to the URL, overriding any previous start parameter.
|
43
|
-
url = orig_url + "&S=#{start + all_results.size}"
|
42
|
+
url = orig_url + "#{query ? '&' : '?'}S=#{start + all_results.size}"
|
44
43
|
end
|
45
44
|
|
46
45
|
all_results
|
data/lib/gerry/version.rb
CHANGED
data/spec/changes_spec.rb
CHANGED
@@ -1,32 +1,49 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe '.changes' do
|
3
|
+
describe '.changes' do
|
4
4
|
it 'should fetch all changes' do
|
5
|
-
stub = stub_get('/changes/', 'changes.json')
|
6
|
-
|
5
|
+
stub = stub_get('/changes/', 'changes.json')
|
6
|
+
|
7
7
|
client = MockGerry.new
|
8
8
|
changes = client.changes
|
9
|
-
|
9
|
+
|
10
10
|
expect(stub).to have_been_requested
|
11
|
-
|
11
|
+
|
12
12
|
expect(changes[0]['project']).to eq('awesome')
|
13
13
|
expect(changes[0]['branch']).to eq('master')
|
14
|
-
|
14
|
+
|
15
15
|
expect(changes[1]['project']).to eq('clean')
|
16
16
|
expect(changes[1]['subject']).to eq('Refactor code')
|
17
17
|
expect(changes[1]['owner']['name']).to eq('Batman')
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
|
+
it 'should fetch all changes in batches' do
|
21
|
+
stub_batch_0 = stub_get('/changes/', 'changes_batch_0.json')
|
22
|
+
stub_batch_1 = stub_get('/changes/?S=1', 'changes_batch_1.json')
|
23
|
+
|
24
|
+
client = MockGerry.new
|
25
|
+
changes = client.changes
|
26
|
+
|
27
|
+
expect(stub_batch_0).to have_been_requested
|
28
|
+
expect(stub_batch_1).to have_been_requested
|
29
|
+
|
30
|
+
expect(changes[0]['project']).to eq('awesome')
|
31
|
+
expect(changes[0]['branch']).to eq('master')
|
32
|
+
|
33
|
+
expect(changes[1]['project']).to eq('clean')
|
34
|
+
expect(changes[1]['subject']).to eq('Refactor code')
|
35
|
+
expect(changes[1]['owner']['name']).to eq('Batman')
|
36
|
+
end
|
37
|
+
|
20
38
|
it 'should fetch all open changes' do
|
21
|
-
|
22
|
-
|
23
|
-
|
39
|
+
stub = stub_get('/changes/?q=is:open+owner:self', 'open_changes.json')
|
40
|
+
|
24
41
|
client = MockGerry.new
|
25
42
|
changes = client.changes(['q=is:open+owner:self'])
|
26
|
-
|
43
|
+
|
27
44
|
expect(stub).to have_been_requested
|
28
|
-
|
45
|
+
|
29
46
|
expect(changes[0]['status']).to eq('OPEN')
|
30
47
|
expect(changes[0]['owner']['name']).to eq('The Duke')
|
31
48
|
end
|
32
|
-
end
|
49
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
)]}'
|
2
|
+
[
|
3
|
+
{
|
4
|
+
"project": "awesome",
|
5
|
+
"branch": "master",
|
6
|
+
"id": "Idd8747a5ea93bb9bddf7695bab25670be135f777",
|
7
|
+
"subject": "Add an awesome feature",
|
8
|
+
"status": "NEW",
|
9
|
+
"created": "2012-09-12 15:54:21.531000000",
|
10
|
+
"updated": "2012-10-13 01:34:40.511000000",
|
11
|
+
"_sortkey": "00115dfe00009334",
|
12
|
+
"_number": 3,
|
13
|
+
"owner": {
|
14
|
+
"name": "The Duke"
|
15
|
+
},
|
16
|
+
"_more_changes": true
|
17
|
+
}
|
18
|
+
]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
)]}'
|
2
|
+
[
|
3
|
+
{
|
4
|
+
"project": "clean",
|
5
|
+
"branch": "master",
|
6
|
+
"id": "Idac803deea68faa1294b3fa5bf814277e899f075",
|
7
|
+
"subject": "Refactor code",
|
8
|
+
"status": "NEW",
|
9
|
+
"created": "2012-09-12 15:51:30.605000000",
|
10
|
+
"updated": "2012-10-13 00:45:26.431000000",
|
11
|
+
"_sortkey": "00205dcddd00937d",
|
12
|
+
"_number": 42,
|
13
|
+
"owner": {
|
14
|
+
"name": "Batman"
|
15
|
+
}
|
16
|
+
}
|
17
|
+
]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gerry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabian Mettler
|
@@ -150,6 +150,8 @@ files:
|
|
150
150
|
- spec/fixtures/account_groups.json
|
151
151
|
- spec/fixtures/capabilities.json
|
152
152
|
- spec/fixtures/changes.json
|
153
|
+
- spec/fixtures/changes_batch_0.json
|
154
|
+
- spec/fixtures/changes_batch_1.json
|
153
155
|
- spec/fixtures/group_members.json
|
154
156
|
- spec/fixtures/groups.json
|
155
157
|
- spec/fixtures/open_changes.json
|
@@ -191,6 +193,8 @@ test_files:
|
|
191
193
|
- spec/fixtures/account_groups.json
|
192
194
|
- spec/fixtures/capabilities.json
|
193
195
|
- spec/fixtures/changes.json
|
196
|
+
- spec/fixtures/changes_batch_0.json
|
197
|
+
- spec/fixtures/changes_batch_1.json
|
194
198
|
- spec/fixtures/group_members.json
|
195
199
|
- spec/fixtures/groups.json
|
196
200
|
- spec/fixtures/open_changes.json
|