gds-api-adapters 36.4.1 → 37.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -12
- data/Rakefile +5 -0
- data/lib/gds_api/asset_manager.rb +3 -3
- data/lib/gds_api/config.rb +58 -11
- data/lib/gds_api/gov_uk_delivery.rb +1 -1
- data/lib/gds_api/json_client.rb +0 -20
- data/lib/gds_api/part_methods.rb +11 -8
- data/lib/gds_api/publisher.rb +5 -4
- data/lib/gds_api/publishing_api_v2.rb +18 -1
- data/lib/gds_api/response.rb +7 -3
- data/lib/gds_api/test_helpers/rummager.rb +12 -0
- data/lib/gds_api/version.rb +1 -1
- data/test/asset_manager_test.rb +6 -14
- data/test/content_api_test.rb +105 -30
- data/test/content_store_test.rb +10 -22
- data/test/gov_uk_delivery_test.rb +5 -3
- data/test/json_client_test.rb +188 -173
- data/test/licence_application_api_test.rb +15 -7
- data/test/list_response_test.rb +23 -8
- data/test/local_links_manager_api_test.rb +14 -12
- data/test/mapit_test.rb +8 -4
- data/test/need_api_test.rb +35 -14
- data/test/organisations_api_test.rb +11 -6
- data/test/panopticon_test.rb +13 -5
- data/test/publisher_api_test.rb +4 -4
- data/test/publishing_api_v2/get_expanded_links_test.rb +3 -3
- data/test/publishing_api_v2/get_links_test.rb +8 -4
- data/test/publishing_api_v2_test.rb +47 -37
- data/test/response_test.rb +49 -20
- data/test/router_test.rb +24 -20
- data/test/rummager_helpers_test.rb +1 -1
- data/test/worldwide_api_test.rb +18 -7
- metadata +17 -3
@@ -72,10 +72,12 @@ EOS
|
|
72
72
|
assert_nil api.details_for_licence(nil)
|
73
73
|
end
|
74
74
|
|
75
|
-
def
|
75
|
+
def test_should_raise_if_licence_is_unrecognised
|
76
76
|
licence_does_not_exist('bloop')
|
77
77
|
|
78
|
-
|
78
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
79
|
+
api.details_for_licence("bloop")
|
80
|
+
end
|
79
81
|
end
|
80
82
|
|
81
83
|
def test_should_provide_full_licence_details_for_canonical_id
|
@@ -90,16 +92,20 @@ EOS
|
|
90
92
|
assert_equal expected, api.details_for_licence("590001").to_hash
|
91
93
|
end
|
92
94
|
|
93
|
-
def
|
95
|
+
def test_should_raise_for_bad_snac_code_entry
|
94
96
|
licence_does_not_exist('590001/bleep')
|
95
97
|
|
96
|
-
|
98
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
99
|
+
api.details_for_licence("590001", "bleep")
|
100
|
+
end
|
97
101
|
end
|
98
102
|
|
99
|
-
def
|
103
|
+
def test_should_raise_for_bad_licence_id_and_snac_code
|
100
104
|
licence_does_not_exist('bloop/bleep')
|
101
105
|
|
102
|
-
|
106
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
107
|
+
api.details_for_licence("bloop", "bleep")
|
108
|
+
end
|
103
109
|
end
|
104
110
|
|
105
111
|
def test_should_return_error_message_to_pick_a_relevant_snac_code_for_the_provided_licence_id
|
@@ -108,7 +114,9 @@ EOS
|
|
108
114
|
to_return(status: 404,
|
109
115
|
body: "{\"error\": \"No authorities found for the licence 590001 and for the snacCode sw10\"}")
|
110
116
|
|
111
|
-
|
117
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
118
|
+
api.details_for_licence("590001", "sw10")
|
119
|
+
end
|
112
120
|
end
|
113
121
|
|
114
122
|
def test_should_return_full_licence_details_with_location_specific_information
|
data/test/list_response_test.rb
CHANGED
@@ -80,12 +80,27 @@ describe GdsApi::ListResponse do
|
|
80
80
|
]
|
81
81
|
}
|
82
82
|
}
|
83
|
-
@p1_response = stub(
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
83
|
+
@p1_response = stub(
|
84
|
+
body: page_1.to_json,
|
85
|
+
status: 200,
|
86
|
+
headers: {
|
87
|
+
link: '<http://www.example.com/1>; rel="self", <http://www.example.com/2>; rel="next"'
|
88
|
+
}
|
89
|
+
)
|
90
|
+
@p2_response = stub(
|
91
|
+
body: page_2.to_json,
|
92
|
+
status: 200,
|
93
|
+
headers: {
|
94
|
+
link: '<http://www.example.com/2>; rel="self", <http://www.example.com/3>; rel="next", <http://www.example.com/1>; rel="previous"'
|
95
|
+
}
|
96
|
+
)
|
97
|
+
@p3_response = stub(
|
98
|
+
body: page_3.to_json,
|
99
|
+
status: 200,
|
100
|
+
headers: {
|
101
|
+
link: '<http://www.example.com/3>; rel="self", <http://www.example.com/1>; rel="previous"'
|
102
|
+
}
|
103
|
+
)
|
89
104
|
|
90
105
|
@client = stub()
|
91
106
|
@client.stubs(:get_list!).with("http://www.example.com/1").returns(GdsApi::ListResponse.new(@p1_response, @client))
|
@@ -97,7 +112,7 @@ describe GdsApi::ListResponse do
|
|
97
112
|
it "should allow accessing the next page" do
|
98
113
|
resp = GdsApi::ListResponse.new(@p1_response, @client)
|
99
114
|
assert resp.has_next_page?
|
100
|
-
assert_equal %w(foo2 bar2), resp.next_page
|
115
|
+
assert_equal %w(foo2 bar2), resp.next_page['results']
|
101
116
|
end
|
102
117
|
|
103
118
|
it "should return nil with no next page" do
|
@@ -121,7 +136,7 @@ describe GdsApi::ListResponse do
|
|
121
136
|
it "should allow accessing the previous page" do
|
122
137
|
resp = GdsApi::ListResponse.new(@p2_response, @client)
|
123
138
|
assert resp.has_previous_page?
|
124
|
-
assert_equal %w(foo1 bar1), resp.previous_page
|
139
|
+
assert_equal %w(foo1 bar1), resp.previous_page['results']
|
125
140
|
end
|
126
141
|
|
127
142
|
it "should return nil with no previous page" do
|
@@ -145,25 +145,28 @@ describe GdsApi::LocalLinksManager do
|
|
145
145
|
end
|
146
146
|
|
147
147
|
describe "when making request with invalid required parameters" do
|
148
|
-
it "
|
148
|
+
it "raises when authority_slug is invalid" do
|
149
149
|
local_links_manager_does_not_have_required_objects("hogwarts", 2)
|
150
150
|
|
151
|
-
|
152
|
-
|
151
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
152
|
+
@api.local_link("hogwarts", 2)
|
153
|
+
end
|
153
154
|
end
|
154
155
|
|
155
|
-
it "
|
156
|
+
it "raises when LGSL is invalid" do
|
156
157
|
local_links_manager_does_not_have_required_objects("blackburn", 999)
|
157
158
|
|
158
|
-
|
159
|
-
|
159
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
160
|
+
@api.local_link("blackburn", 999)
|
161
|
+
end
|
160
162
|
end
|
161
163
|
|
162
|
-
it "
|
164
|
+
it "raises when the LGSL and LGIL combination is invalid" do
|
163
165
|
local_links_manager_does_not_have_required_objects("blackburn", 2, 9)
|
164
166
|
|
165
|
-
|
166
|
-
|
167
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
168
|
+
@api.local_link("blackburn", 2, 9)
|
169
|
+
end
|
167
170
|
end
|
168
171
|
end
|
169
172
|
end
|
@@ -223,11 +226,10 @@ describe GdsApi::LocalLinksManager do
|
|
223
226
|
end
|
224
227
|
|
225
228
|
describe 'when making a request with invalid required parameters' do
|
226
|
-
it "
|
229
|
+
it "raises when authority_slug is invalid" do
|
227
230
|
local_links_manager_does_not_have_an_authority("hogwarts")
|
228
231
|
|
229
|
-
|
230
|
-
assert_equal nil, response
|
232
|
+
assert_raises(GdsApi::HTTPNotFound) { @api.local_authority("hogwarts") }
|
231
233
|
end
|
232
234
|
end
|
233
235
|
end
|
data/test/mapit_test.rb
CHANGED
@@ -45,10 +45,12 @@ describe GdsApi::Mapit do
|
|
45
45
|
assert_equal "30UN", response.areas.last.codes['ons']
|
46
46
|
end
|
47
47
|
|
48
|
-
it "should
|
48
|
+
it "should raise if a postcode doesn't exist" do
|
49
49
|
mapit_does_not_have_a_postcode("SW1A 1AA")
|
50
50
|
|
51
|
-
|
51
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
52
|
+
@api.location_for_postcode("SW1A 1AA")
|
53
|
+
end
|
52
54
|
end
|
53
55
|
|
54
56
|
it "should return 400 for an invalid postcode" do
|
@@ -83,7 +85,7 @@ describe GdsApi::Mapit do
|
|
83
85
|
it "should return and empty result for an unknown area type" do
|
84
86
|
response = @api.areas_for_type('FOO')
|
85
87
|
|
86
|
-
assert_empty response
|
88
|
+
assert_empty response.parsed_content
|
87
89
|
end
|
88
90
|
end
|
89
91
|
|
@@ -109,7 +111,9 @@ describe GdsApi::Mapit do
|
|
109
111
|
end
|
110
112
|
|
111
113
|
it "should return 404 for a missing area of a certain code type" do
|
112
|
-
|
114
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
115
|
+
@api.area_for_code('govuk_slug', 'neverland')
|
116
|
+
end
|
113
117
|
end
|
114
118
|
end
|
115
119
|
end
|
data/test/need_api_test.rb
CHANGED
@@ -38,24 +38,24 @@ describe GdsApi::NeedApi do
|
|
38
38
|
needs = @api.needs_by_id(1,2,3)
|
39
39
|
|
40
40
|
assert_equal 3, needs.count
|
41
|
-
assert_equal %w(1 2 3), needs.map
|
42
|
-
assert_equal "apply for a primary school place", needs
|
43
|
-
assert_equal "find out about becoming a British citizen", needs
|
44
|
-
assert_equal "find out about unemployment benefits", needs
|
41
|
+
assert_equal %w(1 2 3), needs.map { |need| need['id'] }
|
42
|
+
assert_equal "apply for a primary school place", needs['results'][0]['goal']
|
43
|
+
assert_equal "find out about becoming a British citizen", needs['results'][1]['goal']
|
44
|
+
assert_equal "find out about unemployment benefits", needs['results'][2]['goal']
|
45
45
|
end
|
46
46
|
|
47
47
|
it "makes the same request regardless of the order of the IDs" do
|
48
48
|
needs = @api.needs_by_id(2,1,3)
|
49
49
|
|
50
50
|
assert_equal 3, needs.count
|
51
|
-
assert_equal %w(1 2 3), needs.map
|
51
|
+
assert_equal %w(1 2 3), needs.map { |need| need['id'] }
|
52
52
|
end
|
53
53
|
|
54
54
|
it "correctly sorts IDs requested as strings" do
|
55
55
|
needs = @api.needs_by_id(%w(02 3 1))
|
56
56
|
|
57
57
|
assert_equal 3, needs.count
|
58
|
-
assert_equal %w(1 2 3), needs.map
|
58
|
+
assert_equal %w(1 2 3), needs.map { |need| need['id'] }
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -109,12 +109,30 @@ describe GdsApi::NeedApi do
|
|
109
109
|
assert_requested(req)
|
110
110
|
assert_equal 2, needs.count
|
111
111
|
|
112
|
-
assert_equal
|
113
|
-
assert_equal
|
114
|
-
|
112
|
+
assert_equal %w(parent user), needs.map { |need| need['role'] }
|
113
|
+
assert_equal(
|
114
|
+
[
|
115
|
+
"apply for a primary school place",
|
116
|
+
"find out about becoming a British citizen"
|
117
|
+
],
|
118
|
+
needs.map { |need| need['goal'] }
|
119
|
+
)
|
120
|
+
assert_equal(
|
121
|
+
[
|
122
|
+
"my child can start school",
|
123
|
+
"i can take the correct steps to apply for citizenship"
|
124
|
+
],
|
125
|
+
needs.map { |need| need['benefit'] }
|
126
|
+
)
|
115
127
|
|
116
|
-
assert_equal
|
117
|
-
|
128
|
+
assert_equal(
|
129
|
+
"department-for-education",
|
130
|
+
needs.first['organisations'].first['id']
|
131
|
+
)
|
132
|
+
assert_equal(
|
133
|
+
"Department for Education",
|
134
|
+
needs.first['organisations'].first['name']
|
135
|
+
)
|
118
136
|
end
|
119
137
|
end
|
120
138
|
|
@@ -189,12 +207,15 @@ describe GdsApi::NeedApi do
|
|
189
207
|
need_api_has_need(need)
|
190
208
|
|
191
209
|
need_response = @api.need(100500)
|
192
|
-
assert_equal "good things", need_response
|
210
|
+
assert_equal "good things", need_response['benefit']
|
193
211
|
end
|
194
212
|
|
195
|
-
it "should
|
213
|
+
it "should raise for a missing need" do
|
196
214
|
need_api_has_no_need(100600)
|
197
|
-
|
215
|
+
|
216
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
217
|
+
@api.need(100600)
|
218
|
+
end
|
198
219
|
end
|
199
220
|
end
|
200
221
|
|
@@ -16,8 +16,8 @@ describe GdsApi::Organisations do
|
|
16
16
|
organisations_api_has_organisations(organisation_slugs)
|
17
17
|
|
18
18
|
response = @api.organisations
|
19
|
-
assert_equal organisation_slugs, response.map {|r| r
|
20
|
-
assert_equal "Tea Agency", response
|
19
|
+
assert_equal organisation_slugs, response.map { |r| r['details']['slug'] }
|
20
|
+
assert_equal "Tea Agency", response['results'][1]['title']
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should handle the pagination" do
|
@@ -25,7 +25,10 @@ describe GdsApi::Organisations do
|
|
25
25
|
organisations_api_has_organisations(organisation_slugs)
|
26
26
|
|
27
27
|
response = @api.organisations
|
28
|
-
assert_equal
|
28
|
+
assert_equal(
|
29
|
+
organisation_slugs,
|
30
|
+
response.with_subsequent_pages.map { |r| r['details']['slug'] }
|
31
|
+
)
|
29
32
|
end
|
30
33
|
|
31
34
|
it "should raise error if endpoint 404s" do
|
@@ -41,13 +44,15 @@ describe GdsApi::Organisations do
|
|
41
44
|
organisations_api_has_organisation('ministry-of-fun')
|
42
45
|
|
43
46
|
response = @api.organisation('ministry-of-fun')
|
44
|
-
assert_equal 'Ministry Of Fun', response
|
47
|
+
assert_equal 'Ministry Of Fun', response['title']
|
45
48
|
end
|
46
49
|
|
47
|
-
it "should
|
50
|
+
it "should raise for a non-existent organisation" do
|
48
51
|
organisations_api_does_not_have_organisation('non-existent')
|
49
52
|
|
50
|
-
|
53
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
54
|
+
@api.organisation('non-existent')
|
55
|
+
end
|
51
56
|
end
|
52
57
|
end
|
53
58
|
end
|
data/test/panopticon_test.rb
CHANGED
@@ -39,7 +39,7 @@ describe GdsApi::Panopticon do
|
|
39
39
|
panopticon_has_metadata(basic_artefact)
|
40
40
|
|
41
41
|
artefact = api.artefact_for_slug(basic_artefact[:slug])
|
42
|
-
assert_equal 'An artefact', artefact
|
42
|
+
assert_equal 'An artefact', artefact['name']
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'fetches an artefact as a hash given a slug' do
|
@@ -55,11 +55,13 @@ describe GdsApi::Panopticon do
|
|
55
55
|
assert_equal 1, api.get_json(url)['a']
|
56
56
|
end
|
57
57
|
|
58
|
-
it '
|
58
|
+
it 'raises if the endpoint returns 404' do
|
59
59
|
url = "#{base_api_endpoint}/some.json"
|
60
60
|
stub_request(:get, url).to_return(status: Rack::Utils.status_code(:not_found))
|
61
61
|
|
62
|
-
|
62
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
63
|
+
api.get_json(url)
|
64
|
+
end
|
63
65
|
end
|
64
66
|
|
65
67
|
it 'constructs the correct URL for a slug' do
|
@@ -70,8 +72,14 @@ describe GdsApi::Panopticon do
|
|
70
72
|
panopticon_has_metadata(artefact_with_contact)
|
71
73
|
|
72
74
|
artefact = api.artefact_for_slug(artefact_with_contact[:slug])
|
73
|
-
assert_equal
|
74
|
-
|
75
|
+
assert_equal(
|
76
|
+
'Department for Environment, Food and Rural Affairs (Defra)',
|
77
|
+
artefact['contact']['name']
|
78
|
+
)
|
79
|
+
assert_equal(
|
80
|
+
'helpline@defra.gsi.gov.uk',
|
81
|
+
artefact['contact']['email_address']
|
82
|
+
)
|
75
83
|
end
|
76
84
|
|
77
85
|
it 'creates a new artefact' do
|
data/test/publisher_api_test.rb
CHANGED
@@ -59,7 +59,7 @@ describe GdsApi::Publisher do
|
|
59
59
|
publication_exists(basic_answer)
|
60
60
|
pub = api.publication_for_slug(basic_answer['slug'])
|
61
61
|
|
62
|
-
assert_equal "Something", pub
|
62
|
+
assert_equal "Something", pub['body']
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should optionally accept an edition id" do
|
@@ -84,8 +84,8 @@ describe GdsApi::Publisher do
|
|
84
84
|
it "should deserialise parts into whole objects" do
|
85
85
|
publication_exists(publication_with_parts)
|
86
86
|
pub = api.publication_for_slug(publication_with_parts['slug'])
|
87
|
-
assert_equal 3, pub
|
88
|
-
assert_equal "introduction", pub
|
87
|
+
assert_equal 3, pub['parts'].size
|
88
|
+
assert_equal "introduction", pub['parts'].first['slug']
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should have part specific methods for a publication with parts" do
|
@@ -97,7 +97,7 @@ describe GdsApi::Publisher do
|
|
97
97
|
it "should deserialise updated at as a time" do
|
98
98
|
publication_exists(publication_with_parts)
|
99
99
|
pub = api.publication_for_slug(publication_with_parts['slug'])
|
100
|
-
assert_equal Time, pub
|
100
|
+
assert_equal Time, pub['updated_at'].class
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should be able to retrieve local transaction details" do
|
@@ -77,9 +77,9 @@ describe GdsApi::PublishingApiV2 do
|
|
77
77
|
status: 404
|
78
78
|
)
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
81
|
+
@api_client.get_expanded_links(@content_id)
|
82
|
+
end
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
@@ -33,7 +33,10 @@ describe GdsApi::PublishingApiV2 do
|
|
33
33
|
it "responds with the links" do
|
34
34
|
response = @api_client.get_links(@content_id)
|
35
35
|
assert_equal 200, response.code
|
36
|
-
assert_equal
|
36
|
+
assert_equal(
|
37
|
+
["20583132-1619-4c68-af24-77583172c070"],
|
38
|
+
response['links']['organisations']
|
39
|
+
)
|
37
40
|
end
|
38
41
|
end
|
39
42
|
|
@@ -58,7 +61,7 @@ describe GdsApi::PublishingApiV2 do
|
|
58
61
|
it "responds with the empty link set" do
|
59
62
|
response = @api_client.get_links(@content_id)
|
60
63
|
assert_equal 200, response.code
|
61
|
-
assert_equal
|
64
|
+
assert_equal({}, response['links'])
|
62
65
|
end
|
63
66
|
end
|
64
67
|
|
@@ -77,8 +80,9 @@ describe GdsApi::PublishingApiV2 do
|
|
77
80
|
end
|
78
81
|
|
79
82
|
it "responds with 404" do
|
80
|
-
|
81
|
-
|
83
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
84
|
+
@api_client.get_links(@content_id)
|
85
|
+
end
|
82
86
|
end
|
83
87
|
end
|
84
88
|
end
|
@@ -493,7 +493,9 @@ describe GdsApi::PublishingApiV2 do
|
|
493
493
|
end
|
494
494
|
|
495
495
|
it "responds with 404" do
|
496
|
-
|
496
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
497
|
+
@api_client.get_content(@content_id)
|
498
|
+
end
|
497
499
|
end
|
498
500
|
end
|
499
501
|
end
|
@@ -951,7 +953,10 @@ describe GdsApi::PublishingApiV2 do
|
|
951
953
|
organisations: ["591436ab-c2ae-416f-a3c5-1901d633fbfb"],
|
952
954
|
})
|
953
955
|
assert_equal 200, response.code
|
954
|
-
assert_equal
|
956
|
+
assert_equal(
|
957
|
+
["591436ab-c2ae-416f-a3c5-1901d633fbfb"],
|
958
|
+
response['links']['organisations']
|
959
|
+
)
|
955
960
|
end
|
956
961
|
end
|
957
962
|
|
@@ -989,10 +994,13 @@ describe GdsApi::PublishingApiV2 do
|
|
989
994
|
})
|
990
995
|
|
991
996
|
assert_equal 200, response.code
|
992
|
-
assert_equal(
|
993
|
-
|
994
|
-
|
995
|
-
|
997
|
+
assert_equal(
|
998
|
+
{
|
999
|
+
'topics' => ["225df4a8-2945-4e9b-8799-df7424a90b69"],
|
1000
|
+
'organisations' => ["20583132-1619-4c68-af24-77583172c070"],
|
1001
|
+
},
|
1002
|
+
response['links']
|
1003
|
+
)
|
996
1004
|
end
|
997
1005
|
end
|
998
1006
|
|
@@ -1027,7 +1035,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1027
1035
|
})
|
1028
1036
|
|
1029
1037
|
assert_equal 200, response.code
|
1030
|
-
assert_equal
|
1038
|
+
assert_equal({}, response['links'])
|
1031
1039
|
end
|
1032
1040
|
end
|
1033
1041
|
|
@@ -1064,9 +1072,12 @@ describe GdsApi::PublishingApiV2 do
|
|
1064
1072
|
})
|
1065
1073
|
|
1066
1074
|
assert_equal 200, response.code
|
1067
|
-
assert_equal(
|
1068
|
-
|
1069
|
-
|
1075
|
+
assert_equal(
|
1076
|
+
{
|
1077
|
+
'organisations' => ["591436ab-c2ae-416f-a3c5-1901d633fbfb"],
|
1078
|
+
},
|
1079
|
+
response['links']
|
1080
|
+
)
|
1070
1081
|
end
|
1071
1082
|
end
|
1072
1083
|
|
@@ -1214,7 +1225,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1214
1225
|
.with(
|
1215
1226
|
method: :get,
|
1216
1227
|
path: "/v2/content",
|
1217
|
-
query: "
|
1228
|
+
query: "document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path",
|
1218
1229
|
headers: GdsApi::JsonClient.default_request_headers.merge(
|
1219
1230
|
"Authorization" => "Bearer #{@bearer_token}"
|
1220
1231
|
),
|
@@ -1226,7 +1237,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1226
1237
|
pages: 1,
|
1227
1238
|
current_page: 1,
|
1228
1239
|
links: [{
|
1229
|
-
href: "http://example.org/v2/content?
|
1240
|
+
href: "http://example.org/v2/content?document_type=topic&fields[]=title&fields[]=base_path&page=1",
|
1230
1241
|
rel: "self"
|
1231
1242
|
}],
|
1232
1243
|
results: [
|
@@ -1237,7 +1248,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1237
1248
|
)
|
1238
1249
|
|
1239
1250
|
response = @api_client.get_content_items(
|
1240
|
-
|
1251
|
+
document_type: 'topic',
|
1241
1252
|
fields: [:title, :base_path],
|
1242
1253
|
)
|
1243
1254
|
|
@@ -1247,7 +1258,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1247
1258
|
["total", 2],
|
1248
1259
|
["pages", 1],
|
1249
1260
|
["current_page", 1],
|
1250
|
-
["links", [{"href"=>"http://example.org/v2/content?
|
1261
|
+
["links", [{"href"=>"http://example.org/v2/content?document_type=topic&fields[]=title&fields[]=base_path&page=1", "rel"=>"self"}]],
|
1251
1262
|
["results", [{"title"=>"Content Item A", "base_path"=>"/a-base-path"}, {"title"=>"Content Item B", "base_path"=>"/another-base-path"}]]
|
1252
1263
|
], response.to_a
|
1253
1264
|
|
@@ -1260,7 +1271,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1260
1271
|
.with(
|
1261
1272
|
method: :get,
|
1262
1273
|
path: "/v2/content",
|
1263
|
-
query: "
|
1274
|
+
query: "document_type=topic&fields%5B%5D=content_id&fields%5B%5D=locale",
|
1264
1275
|
headers: GdsApi::JsonClient.default_request_headers.merge(
|
1265
1276
|
"Authorization" => "Bearer #{@bearer_token}"
|
1266
1277
|
),
|
@@ -1272,7 +1283,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1272
1283
|
pages: 1,
|
1273
1284
|
current_page: 1,
|
1274
1285
|
links: [{
|
1275
|
-
href: "http://example.org/v2/content?
|
1286
|
+
href: "http://example.org/v2/content?document_type=topic&fields[]=content_id&fields[]=locale&page=1",
|
1276
1287
|
rel: "self"
|
1277
1288
|
}],
|
1278
1289
|
results: [
|
@@ -1282,7 +1293,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1282
1293
|
)
|
1283
1294
|
|
1284
1295
|
response = @api_client.get_content_items(
|
1285
|
-
|
1296
|
+
document_type: 'topic',
|
1286
1297
|
fields: [:content_id, :locale],
|
1287
1298
|
)
|
1288
1299
|
|
@@ -1292,7 +1303,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1292
1303
|
["total", 1],
|
1293
1304
|
["pages", 1],
|
1294
1305
|
["current_page", 1],
|
1295
|
-
["links", [{"href"=>"http://example.org/v2/content?
|
1306
|
+
["links", [{"href"=>"http://example.org/v2/content?document_type=topic&fields[]=content_id&fields[]=locale&page=1", "rel"=>"self"}]],
|
1296
1307
|
["results", [{"content_id"=>"bed722e6-db68-43e5-9079-063f623335a7", "locale"=>"en"}]]
|
1297
1308
|
], response.to_a
|
1298
1309
|
end
|
@@ -1304,7 +1315,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1304
1315
|
.with(
|
1305
1316
|
method: :get,
|
1306
1317
|
path: "/v2/content",
|
1307
|
-
query: "
|
1318
|
+
query: "document_type=topic&fields%5B%5D=content_id&fields%5B%5D=locale&locale=fr",
|
1308
1319
|
headers: GdsApi::JsonClient.default_request_headers.merge(
|
1309
1320
|
"Authorization" => "Bearer #{@bearer_token}"
|
1310
1321
|
),
|
@@ -1316,7 +1327,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1316
1327
|
pages: 1,
|
1317
1328
|
current_page: 1,
|
1318
1329
|
links: [{
|
1319
|
-
href: "http://example.org/v2/content?
|
1330
|
+
href: "http://example.org/v2/content?document_type=topic&fields[]=content_id&fields[]=locale&locale=fr&page=1",
|
1320
1331
|
rel: "self"
|
1321
1332
|
}],
|
1322
1333
|
results: [
|
@@ -1326,7 +1337,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1326
1337
|
)
|
1327
1338
|
|
1328
1339
|
response = @api_client.get_content_items(
|
1329
|
-
|
1340
|
+
document_type: 'topic',
|
1330
1341
|
fields: [:content_id, :locale],
|
1331
1342
|
locale: 'fr',
|
1332
1343
|
)
|
@@ -1336,7 +1347,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1336
1347
|
["total", 1],
|
1337
1348
|
["pages", 1],
|
1338
1349
|
["current_page", 1],
|
1339
|
-
["links", [{"href"=>"http://example.org/v2/content?
|
1350
|
+
["links", [{"href"=>"http://example.org/v2/content?document_type=topic&fields[]=content_id&fields[]=locale&locale=fr&page=1", "rel"=>"self"}]],
|
1340
1351
|
["results", [{"content_id"=>"bed722e6-db68-43e5-9079-063f623335a7", "locale"=>"fr"}]]
|
1341
1352
|
], response.to_a
|
1342
1353
|
end
|
@@ -1348,7 +1359,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1348
1359
|
.with(
|
1349
1360
|
method: :get,
|
1350
1361
|
path: "/v2/content",
|
1351
|
-
query: "
|
1362
|
+
query: "document_type=topic&fields%5B%5D=content_id&fields%5B%5D=locale&locale=all",
|
1352
1363
|
headers: GdsApi::JsonClient.default_request_headers.merge(
|
1353
1364
|
"Authorization" => "Bearer #{@bearer_token}"
|
1354
1365
|
),
|
@@ -1360,7 +1371,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1360
1371
|
pages: 1,
|
1361
1372
|
current_page: 1,
|
1362
1373
|
links: [{
|
1363
|
-
href: "http://example.org/v2/content?
|
1374
|
+
href: "http://example.org/v2/content?document_type=topic&fields[]=content_id&fields[]=locale&locale=all&page=1",
|
1364
1375
|
rel: "self"
|
1365
1376
|
}],
|
1366
1377
|
results: [
|
@@ -1372,7 +1383,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1372
1383
|
)
|
1373
1384
|
|
1374
1385
|
response = @api_client.get_content_items(
|
1375
|
-
|
1386
|
+
document_type: 'topic',
|
1376
1387
|
fields: [:content_id, :locale],
|
1377
1388
|
locale: 'all',
|
1378
1389
|
)
|
@@ -1382,7 +1393,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1382
1393
|
["total", 3],
|
1383
1394
|
["pages", 1], ["current_page", 1],
|
1384
1395
|
["links",
|
1385
|
-
[{"href"=>"http://example.org/v2/content?
|
1396
|
+
[{"href"=>"http://example.org/v2/content?document_type=topic&fields[]=content_id&fields[]=locale&locale=all&page=1", "rel"=>"self"}]],
|
1386
1397
|
["results",
|
1387
1398
|
[{"content_id"=>"bed722e6-db68-43e5-9079-063f623335a7", "locale"=>"en"},
|
1388
1399
|
{"content_id"=>"bed722e6-db68-43e5-9079-063f623335a7", "locale"=>"fr"},
|
@@ -1397,7 +1408,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1397
1408
|
.with(
|
1398
1409
|
method: :get,
|
1399
1410
|
path: "/v2/content",
|
1400
|
-
query: "
|
1411
|
+
query: "document_type=topic&fields%5B%5D=content_id&fields%5B%5D=details",
|
1401
1412
|
headers: GdsApi::JsonClient.default_request_headers.merge(
|
1402
1413
|
"Authorization" => "Bearer #{@bearer_token}"
|
1403
1414
|
),
|
@@ -1409,7 +1420,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1409
1420
|
pages: 1,
|
1410
1421
|
current_page: 1,
|
1411
1422
|
links: [{
|
1412
|
-
href: "http://example.org/v2/content?
|
1423
|
+
href: "http://example.org/v2/content?document_type=topic&fields[]=content_id&fields[]=details&page=1",
|
1413
1424
|
rel: "self"
|
1414
1425
|
}],
|
1415
1426
|
results: [
|
@@ -1419,7 +1430,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1419
1430
|
)
|
1420
1431
|
|
1421
1432
|
response = @api_client.get_content_items(
|
1422
|
-
|
1433
|
+
document_type: 'topic',
|
1423
1434
|
fields: [:content_id, :details],
|
1424
1435
|
)
|
1425
1436
|
|
@@ -1429,7 +1440,7 @@ describe GdsApi::PublishingApiV2 do
|
|
1429
1440
|
["total", 1],
|
1430
1441
|
["pages", 1],
|
1431
1442
|
["current_page", 1],
|
1432
|
-
["links", [{"href"=>"http://example.org/v2/content?
|
1443
|
+
["links", [{"href"=>"http://example.org/v2/content?document_type=topic&fields[]=content_id&fields[]=details&page=1", "rel"=>"self"}]],
|
1433
1444
|
["results", [{"content_id"=>"bed722e6-db68-43e5-9079-063f623335a7", "details"=>{"foo"=>"bar"}}]]
|
1434
1445
|
], response.to_a
|
1435
1446
|
end
|
@@ -1542,14 +1553,13 @@ describe GdsApi::PublishingApiV2 do
|
|
1542
1553
|
end
|
1543
1554
|
|
1544
1555
|
it "404s" do
|
1545
|
-
|
1546
|
-
@
|
1547
|
-
|
1556
|
+
assert_raises(GdsApi::HTTPNotFound) do
|
1557
|
+
@api_client.get_linked_items(
|
1558
|
+
@content_id,
|
1548
1559
|
link_type: "topic",
|
1549
|
-
fields:
|
1550
|
-
|
1551
|
-
|
1552
|
-
assert_nil response
|
1560
|
+
fields: %w(content_id base_path),
|
1561
|
+
)
|
1562
|
+
end
|
1553
1563
|
end
|
1554
1564
|
end
|
1555
1565
|
|