gds-api-adapters 35.0.0 → 35.0.1
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.
- checksums.yaml +4 -4
- data/lib/gds_api/test_helpers/publishing_api_v2.rb +14 -1
- data/lib/gds_api/version.rb +1 -1
- data/test/publishing_api_test.rb +1 -1
- data/test/publishing_api_v2/get_expanded_links_test.rb +1 -1
- data/test/publishing_api_v2/get_links_test.rb +1 -1
- data/test/publishing_api_v2/lookup_test.rb +1 -1
- data/test/publishing_api_v2_test.rb +1 -1
- data/test/test_helpers/pact_helper.rb +7 -1
- data/test/test_helpers/publishing_api_v2_test.rb +41 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e333779f06ac4e6cd7cdc357ecd49415ff7504ff
|
4
|
+
data.tar.gz: 6f5769410683e7342de9505201bf22a1c02732bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e75bf5a23893d51a70361a55f1d2b805658678b569f5e4d2f8bd2cdef3b339f5142d3962ee612dac18841cf592685b5969ed7ad2c27b0dade2800fe1fd9c2df
|
7
|
+
data.tar.gz: db78f0b50042f099c4fc43a2cd71c0286b69bccea372e7add1727cb55da56aa29a59183e9401c8496d6ba4990f51a46eb315891bb63459dada26260969a20f6f
|
@@ -169,7 +169,20 @@ module GdsApi
|
|
169
169
|
#)
|
170
170
|
def publishing_api_has_content(items, params = {})
|
171
171
|
url = PUBLISHING_API_V2_ENDPOINT + "/content"
|
172
|
-
|
172
|
+
per_page = params.fetch(:per_page, 50)
|
173
|
+
page = params.fetch(:page, 1)
|
174
|
+
number_of_pages = items.count < per_page ? 1 : items.count / per_page
|
175
|
+
|
176
|
+
body = {
|
177
|
+
results: items,
|
178
|
+
total: items.count,
|
179
|
+
pages: number_of_pages,
|
180
|
+
current_page: page
|
181
|
+
}
|
182
|
+
|
183
|
+
stub_request(:get, url)
|
184
|
+
.with(query: params)
|
185
|
+
.to_return(status: 200, body: body.to_json, headers: {})
|
173
186
|
end
|
174
187
|
|
175
188
|
# This method has been refactored into publishing_api_has_content (above)
|
data/lib/gds_api/version.rb
CHANGED
data/test/publishing_api_test.rb
CHANGED
@@ -8,7 +8,7 @@ describe GdsApi::PublishingApi do
|
|
8
8
|
|
9
9
|
before do
|
10
10
|
@base_api_url = Plek.current.find("publishing-api")
|
11
|
-
@api_client = GdsApi::PublishingApi.new(
|
11
|
+
@api_client = GdsApi::PublishingApi.new(publishing_api_host)
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "#put_content_item" do
|
@@ -6,7 +6,7 @@ describe GdsApi::PublishingApiV2 do
|
|
6
6
|
include PactTest
|
7
7
|
|
8
8
|
before do
|
9
|
-
@api_client = GdsApi::PublishingApiV2.new(
|
9
|
+
@api_client = GdsApi::PublishingApiV2.new(publishing_api_host)
|
10
10
|
@content_id = "bed722e6-db68-43e5-9079-063f623335a7"
|
11
11
|
end
|
12
12
|
|
@@ -6,7 +6,7 @@ describe GdsApi::PublishingApiV2 do
|
|
6
6
|
include PactTest
|
7
7
|
|
8
8
|
before do
|
9
|
-
@api_client = GdsApi::PublishingApiV2.new(
|
9
|
+
@api_client = GdsApi::PublishingApiV2.new(publishing_api_host)
|
10
10
|
@content_id = "bed722e6-db68-43e5-9079-063f623335a7"
|
11
11
|
end
|
12
12
|
|
@@ -29,7 +29,7 @@ describe GdsApi::PublishingApiV2 do
|
|
29
29
|
@bearer_token = "example-bearer-token"
|
30
30
|
@base_api_url = Plek.current.find("publishing-api")
|
31
31
|
@api_client = GdsApi::PublishingApiV2.new(
|
32
|
-
|
32
|
+
publishing_api_host,
|
33
33
|
bearer_token: @bearer_token,
|
34
34
|
)
|
35
35
|
|
@@ -1,7 +1,13 @@
|
|
1
|
+
PUBLISHING_API_PORT=3001
|
2
|
+
|
3
|
+
def publishing_api_host
|
4
|
+
"http://localhost:#{PUBLISHING_API_PORT}"
|
5
|
+
end
|
6
|
+
|
1
7
|
Pact.service_consumer "GDS API Adapters" do
|
2
8
|
has_pact_with "Publishing API" do
|
3
9
|
mock_service :publishing_api do
|
4
|
-
port
|
10
|
+
port PUBLISHING_API_PORT
|
5
11
|
end
|
6
12
|
end
|
7
13
|
end
|
@@ -25,6 +25,47 @@ describe GdsApi::TestHelpers::PublishingApiV2 do
|
|
25
25
|
|
26
26
|
assert_equal([{ "content_id" => "2878337b-bed9-4e7f-85b6-10ed2cbcd504" }], response)
|
27
27
|
end
|
28
|
+
|
29
|
+
it 'allows params' do
|
30
|
+
publishing_api_has_content(
|
31
|
+
[{
|
32
|
+
"content_id" => "2878337b-bed9-4e7f-85b6-10ed2cbcd504"
|
33
|
+
}],
|
34
|
+
document_type: 'document_collection',
|
35
|
+
query: 'query',
|
36
|
+
)
|
37
|
+
|
38
|
+
response = publishing_api.get_content_items(
|
39
|
+
document_type: 'document_collection',
|
40
|
+
query: 'query'
|
41
|
+
)['results']
|
42
|
+
|
43
|
+
assert_equal(
|
44
|
+
[{ "content_id" => "2878337b-bed9-4e7f-85b6-10ed2cbcd504" }],
|
45
|
+
response
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'returns pagination results' do
|
50
|
+
publishing_api_has_content(
|
51
|
+
[
|
52
|
+
{ "content_id" => "2878337b-bed9-4e7f-85b6-10ed2cbcd504" },
|
53
|
+
{ "content_id" => "2878337b-bed9-4e7f-85b6-10ed2cbcd505" },
|
54
|
+
{ "content_id" => "2878337b-bed9-4e7f-85b6-10ed2cbcd506" },
|
55
|
+
{ "content_id" => "2878337b-bed9-4e7f-85b6-10ed2cbcd507" },
|
56
|
+
],
|
57
|
+
{
|
58
|
+
page: 1,
|
59
|
+
per_page: 2
|
60
|
+
}
|
61
|
+
)
|
62
|
+
|
63
|
+
response = publishing_api.get_content_items({ page: 1, per_page: 2 })
|
64
|
+
|
65
|
+
assert_equal(response['total'], 4)
|
66
|
+
assert_equal(response['pages'], 2)
|
67
|
+
assert_equal(response['current_page'], 1)
|
68
|
+
end
|
28
69
|
end
|
29
70
|
|
30
71
|
describe "#publishing_api_has_expanded_links" do
|