Module: GdsApi::TestHelpers::PublishingApi
Constant Summary
collapse
- PUBLISHING_API_ENDPOINT =
Plek.current.find('publishing-api')
Instance Method Summary
collapse
#content_item_for_base_path, #titleize_base_path
Instance Method Details
#assert_publishing_api_put_item(base_path, attributes = {}) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/gds_api/test_helpers/publishing_api.rb', line 22
def assert_publishing_api_put_item(base_path, attributes = {})
url = PUBLISHING_API_ENDPOINT + "/content" + base_path
if attributes.empty?
assert_requested(:put, url)
else
assert_requested(:put, url) do |req|
data = JSON.parse(req.body)
attributes.to_a.all? do |key, value|
data[key.to_s] == value
end
end
end
end
|
#publishing_api_isnt_available ⇒ Object
36
37
38
|
# File 'lib/gds_api/test_helpers/publishing_api.rb', line 36
def publishing_api_isnt_available
stub_request(:any, /#{PUBLISHING_API_ENDPOINT}\/.*/).to_return(:status => 503)
end
|
#stub_default_publishing_api_put ⇒ Object
18
19
20
|
# File 'lib/gds_api/test_helpers/publishing_api.rb', line 18
def stub_default_publishing_api_put()
stub_request(:put, %r{\A#{PUBLISHING_API_ENDPOINT}/content})
end
|
#stub_publishing_api_put_item(base_path, body = content_item_for_base_path(base_path)) ⇒ Object
12
13
14
15
16
|
# File 'lib/gds_api/test_helpers/publishing_api.rb', line 12
def stub_publishing_api_put_item(base_path, body = content_item_for_base_path(base_path))
url = PUBLISHING_API_ENDPOINT + "/content" + base_path
body = body.to_json unless body.is_a?(String)
stub_request(:put, url).with(body: body).to_return(status: 201, body: body, headers: {})
end
|