gds-api-adapters 10.16.0 → 10.17.0
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.
@@ -11,6 +11,14 @@ class GdsApi::ContentStore < GdsApi::Base
|
|
11
11
|
get_json!(content_item_url(base_path))
|
12
12
|
end
|
13
13
|
|
14
|
+
def put_content_item(base_path, payload)
|
15
|
+
put_json(content_item_url(base_path), payload)
|
16
|
+
end
|
17
|
+
|
18
|
+
def put_content_item!(base_path, payload)
|
19
|
+
put_json!(content_item_url(base_path), payload)
|
20
|
+
end
|
21
|
+
|
14
22
|
private
|
15
23
|
|
16
24
|
def content_item_url(base_path)
|
data/lib/gds_api/exceptions.rb
CHANGED
@@ -14,7 +14,8 @@ module GdsApi
|
|
14
14
|
class HTTPErrorResponse < BaseError
|
15
15
|
attr_accessor :code, :error_details
|
16
16
|
|
17
|
-
def initialize(code, error_details = nil)
|
17
|
+
def initialize(code, message = nil, error_details = nil)
|
18
|
+
super(message)
|
18
19
|
@code = code
|
19
20
|
@error_details = error_details
|
20
21
|
end
|
data/lib/gds_api/json_client.rb
CHANGED
@@ -111,13 +111,13 @@ module GdsApi
|
|
111
111
|
response = do_request(method, url, params)
|
112
112
|
|
113
113
|
rescue RestClient::ResourceNotFound => e
|
114
|
-
raise GdsApi::HTTPNotFound.new(e.http_code)
|
114
|
+
raise GdsApi::HTTPNotFound.new(e.http_code, "url: #{url}")
|
115
115
|
|
116
116
|
rescue RestClient::Gone => e
|
117
|
-
raise GdsApi::HTTPGone.new(e.http_code)
|
117
|
+
raise GdsApi::HTTPGone.new(e.http_code, "url: #{url}")
|
118
118
|
|
119
119
|
rescue RestClient::Exception => e
|
120
|
-
raise GdsApi::HTTPErrorResponse.new(e.response.code.to_i
|
120
|
+
raise GdsApi::HTTPErrorResponse.new(e.response.code.to_i, "url: #{url}\n#{e.response.body}")
|
121
121
|
end
|
122
122
|
|
123
123
|
# method: the symbolic name of the method to use, e.g. :get, :post
|
@@ -132,10 +132,10 @@ module GdsApi
|
|
132
132
|
response = do_request_with_cache(method, url, (params.to_json if params), additional_headers)
|
133
133
|
|
134
134
|
rescue RestClient::ResourceNotFound => e
|
135
|
-
raise GdsApi::HTTPNotFound.new(e.http_code)
|
135
|
+
raise GdsApi::HTTPNotFound.new(e.http_code, "url: #{url}")
|
136
136
|
|
137
137
|
rescue RestClient::Gone => e
|
138
|
-
raise GdsApi::HTTPGone.new(e.http_code)
|
138
|
+
raise GdsApi::HTTPGone.new(e.http_code, "url: #{url}")
|
139
139
|
|
140
140
|
rescue RestClient::Exception => e
|
141
141
|
# Attempt to parse the body as JSON if possible
|
@@ -144,7 +144,7 @@ module GdsApi
|
|
144
144
|
rescue JSON::ParserError
|
145
145
|
nil
|
146
146
|
end
|
147
|
-
raise GdsApi::HTTPErrorResponse.new(e.http_code,
|
147
|
+
raise GdsApi::HTTPErrorResponse.new(e.http_code, "url: #{url}\n#{e.http_body}", error_details)
|
148
148
|
end
|
149
149
|
|
150
150
|
# If no custom response is given, just instantiate Response
|
@@ -13,6 +13,15 @@ module GdsApi
|
|
13
13
|
stub_request(:get, url).to_return(status: 200, body: body.to_json, headers: {})
|
14
14
|
end
|
15
15
|
|
16
|
+
def stub_content_store_put_item(base_path, body = item_for_base_path(base_path))
|
17
|
+
url = CONTENT_STORE_ENDPOINT + "/content" + base_path
|
18
|
+
stub_request(:put, url).with(body: body.to_json).to_return(status: 201, body: body.to_json, headers: {})
|
19
|
+
end
|
20
|
+
|
21
|
+
def stub_default_content_store_put()
|
22
|
+
stub_request(:put, %r{\A#{CONTENT_STORE_ENDPOINT}/content})
|
23
|
+
end
|
24
|
+
|
16
25
|
def item_for_base_path(base_path)
|
17
26
|
{
|
18
27
|
"title" => titleize_slug(base_path),
|
data/lib/gds_api/version.rb
CHANGED
data/test/content_store_test.rb
CHANGED
@@ -17,5 +17,12 @@ describe GdsApi::ContentStore do
|
|
17
17
|
response = @api.content_item(base_path)
|
18
18
|
assert_equal base_path, response["base_path"]
|
19
19
|
end
|
20
|
+
|
21
|
+
it "should create the item" do
|
22
|
+
base_path = "/test-to-content-store"
|
23
|
+
stub_content_store_put_item(base_path)
|
24
|
+
response = @api.put_content_item(base_path, item_for_base_path(base_path))
|
25
|
+
assert_equal base_path, response["base_path"]
|
26
|
+
end
|
20
27
|
end
|
21
28
|
end
|
data/test/router_test.rb
CHANGED
@@ -380,7 +380,7 @@ describe GdsApi::Router do
|
|
380
380
|
|
381
381
|
refute_nil e
|
382
382
|
assert_equal 500, e.code
|
383
|
-
assert_equal "
|
383
|
+
assert_equal "url: #{@base_api_url}/routes/commit\nFailed to update all routers", e.message
|
384
384
|
end
|
385
385
|
end
|
386
386
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 10.
|
4
|
+
version: 10.17.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: plek
|
@@ -382,7 +382,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
382
382
|
version: '0'
|
383
383
|
segments:
|
384
384
|
- 0
|
385
|
-
hash: -
|
385
|
+
hash: -1214932263010117291
|
386
386
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
387
387
|
none: false
|
388
388
|
requirements:
|
@@ -391,7 +391,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
391
391
|
version: '0'
|
392
392
|
segments:
|
393
393
|
- 0
|
394
|
-
hash: -
|
394
|
+
hash: -1214932263010117291
|
395
395
|
requirements: []
|
396
396
|
rubyforge_project:
|
397
397
|
rubygems_version: 1.8.23
|