gds-api-adapters 10.11.2 → 10.12.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.
- data/lib/gds_api/content_store.rb +20 -0
- data/lib/gds_api/helpers.rb +5 -0
- data/lib/gds_api/test_helpers/content_store.rb +31 -0
- data/lib/gds_api/version.rb +1 -1
- data/test/content_store_test.rb +21 -0
- metadata +8 -4
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
require_relative 'exceptions'
|
3
|
+
|
4
|
+
class GdsApi::ContentStore < GdsApi::ContentApi
|
5
|
+
include GdsApi::ExceptionHandling
|
6
|
+
|
7
|
+
def content_item(base_path)
|
8
|
+
get_json(content_item_url(base_path))
|
9
|
+
end
|
10
|
+
|
11
|
+
def content_item!(base_path)
|
12
|
+
get_json!(content_item_url(base_path))
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def content_item_url(base_path)
|
18
|
+
"#{endpoint}/content#{base_path}"
|
19
|
+
end
|
20
|
+
end
|
data/lib/gds_api/helpers.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'gds_api/asset_manager'
|
2
2
|
require 'gds_api/business_support_api'
|
3
3
|
require 'gds_api/content_api'
|
4
|
+
require 'gds_api/content_store'
|
4
5
|
require 'gds_api/fact_cave'
|
5
6
|
require 'gds_api/imminence'
|
6
7
|
require 'gds_api/licence_application'
|
@@ -24,6 +25,10 @@ module GdsApi
|
|
24
25
|
@content_api ||= GdsApi::ContentApi.new(Plek.current.find("contentapi"), options)
|
25
26
|
end
|
26
27
|
|
28
|
+
def content_store(options = {})
|
29
|
+
@content_store ||= GdsApi::ContentStore.new(Plek.current.find("content-store"), options)
|
30
|
+
end
|
31
|
+
|
27
32
|
def fact_cave_api(options = {})
|
28
33
|
@fact_cave_api ||= GdsApi::FactCave.new(Plek.current.find("fact-cave"), options)
|
29
34
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'gds_api/test_helpers/json_client_helper'
|
2
|
+
require 'gds_api/test_helpers/common_responses'
|
3
|
+
|
4
|
+
module GdsApi
|
5
|
+
module TestHelpers
|
6
|
+
module ContentStore
|
7
|
+
include CommonResponses
|
8
|
+
|
9
|
+
CONTENT_STORE_ENDPOINT = Plek.current.find('content-store')
|
10
|
+
|
11
|
+
def content_store_has_item(base_path, body = item_for_base_path(base_path))
|
12
|
+
url = CONTENT_STORE_ENDPOINT + "/content" + base_path
|
13
|
+
stub_request(:get, url).to_return(status: 200, body: body.to_json, headers: {})
|
14
|
+
end
|
15
|
+
|
16
|
+
def item_for_base_path(base_path)
|
17
|
+
{
|
18
|
+
"title" => titleize_slug(base_path),
|
19
|
+
"description" => "Description for #{base_path}",
|
20
|
+
"format" => "guide",
|
21
|
+
"need_ids" => ["100001"],
|
22
|
+
"public_updated_at" => "2014-05-06T12:01:00+00:00",
|
23
|
+
"base_path" => base_path,
|
24
|
+
"details" => {
|
25
|
+
"body" => "Some content for #{base_path}",
|
26
|
+
}
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/gds_api/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'gds_api/content_store'
|
3
|
+
require 'gds_api/test_helpers/content_store'
|
4
|
+
|
5
|
+
describe GdsApi::ContentApi do
|
6
|
+
include GdsApi::TestHelpers::ContentStore
|
7
|
+
|
8
|
+
before do
|
9
|
+
@base_api_url = Plek.current.find("content-store")
|
10
|
+
@api = GdsApi::ContentStore.new(@base_api_url)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "item" do
|
14
|
+
it "should return the item" do
|
15
|
+
base_path = "/test-from-content-store"
|
16
|
+
content_store_has_item(base_path)
|
17
|
+
response = @api.content_item(base_path)
|
18
|
+
assert_equal base_path, response["base_path"]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
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.12.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-05-
|
12
|
+
date: 2014-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: plek
|
@@ -303,6 +303,7 @@ files:
|
|
303
303
|
- lib/gds_api/test_helpers/mapit.rb
|
304
304
|
- lib/gds_api/test_helpers/panopticon.rb
|
305
305
|
- lib/gds_api/test_helpers/json_client_helper.rb
|
306
|
+
- lib/gds_api/test_helpers/content_store.rb
|
306
307
|
- lib/gds_api/test_helpers/asset_manager.rb
|
307
308
|
- lib/gds_api/test_helpers/gov_uk_delivery.rb
|
308
309
|
- lib/gds_api/test_helpers/fact_cave.rb
|
@@ -322,6 +323,7 @@ files:
|
|
322
323
|
- lib/gds_api/helpers.rb
|
323
324
|
- lib/gds_api/middleware/govuk_request_id_sniffer.rb
|
324
325
|
- lib/gds_api/panopticon.rb
|
326
|
+
- lib/gds_api/content_store.rb
|
325
327
|
- lib/gds_api/asset_manager.rb
|
326
328
|
- lib/gds_api/gov_uk_delivery.rb
|
327
329
|
- lib/gds_api/fact_cave.rb
|
@@ -354,6 +356,7 @@ files:
|
|
354
356
|
- test/response_test.rb
|
355
357
|
- test/organisations_api_test.rb
|
356
358
|
- test/imminence_api_test.rb
|
359
|
+
- test/content_store_test.rb
|
357
360
|
- test/asset_manager_test.rb
|
358
361
|
- test/fixtures/hello.txt
|
359
362
|
- test/fixtures/world_organisations_australia.json
|
@@ -379,7 +382,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
379
382
|
version: '0'
|
380
383
|
segments:
|
381
384
|
- 0
|
382
|
-
hash:
|
385
|
+
hash: 331538465080981317
|
383
386
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
384
387
|
none: false
|
385
388
|
requirements:
|
@@ -388,7 +391,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
388
391
|
version: '0'
|
389
392
|
segments:
|
390
393
|
- 0
|
391
|
-
hash:
|
394
|
+
hash: 331538465080981317
|
392
395
|
requirements: []
|
393
396
|
rubyforge_project:
|
394
397
|
rubygems_version: 1.8.23
|
@@ -416,6 +419,7 @@ test_files:
|
|
416
419
|
- test/response_test.rb
|
417
420
|
- test/organisations_api_test.rb
|
418
421
|
- test/imminence_api_test.rb
|
422
|
+
- test/content_store_test.rb
|
419
423
|
- test/asset_manager_test.rb
|
420
424
|
- test/fixtures/hello.txt
|
421
425
|
- test/fixtures/world_organisations_australia.json
|