gds-api-adapters 8.2.2 → 8.2.3
Sign up to get free protection for your applications and to get access to all the features.
data/lib/gds_api/content_api.rb
CHANGED
@@ -52,7 +52,7 @@ class GdsApi::ContentApi < GdsApi::Base
|
|
52
52
|
def with_tag(tag, tag_type=nil)
|
53
53
|
tag_key = key_for_tag_type(tag_type)
|
54
54
|
|
55
|
-
get_list!("#{base_url}/with_tag.json?#{tag_key}=#{CGI.escape(tag)}
|
55
|
+
get_list!("#{base_url}/with_tag.json?#{tag_key}=#{CGI.escape(tag)}")
|
56
56
|
end
|
57
57
|
|
58
58
|
def curated_list(tag, tag_type=nil)
|
@@ -27,7 +27,7 @@ module GdsApi
|
|
27
27
|
if rendering_app
|
28
28
|
hash[:rendering_app] = rendering_app
|
29
29
|
end
|
30
|
-
[:need_id, :section, :indexable_content, :paths, :prefixes].each do |attr_name|
|
30
|
+
[:need_id, :section, :industry_sectors, :indexable_content, :paths, :prefixes].each do |attr_name|
|
31
31
|
if record.respond_to? attr_name
|
32
32
|
hash[attr_name] = record.send(attr_name)
|
33
33
|
end
|
@@ -93,21 +93,50 @@ module GdsApi
|
|
93
93
|
def content_api_has_artefacts_with_a_tag(tag_type, slug, artefact_slugs=[])
|
94
94
|
body = plural_response_base.merge(
|
95
95
|
"results" => artefact_slugs.map do |artefact_slug|
|
96
|
-
|
96
|
+
artefact_for_slug(artefact_slug)
|
97
97
|
end
|
98
98
|
)
|
99
|
+
|
100
|
+
endpoint = "#{CONTENT_API_ENDPOINT}/with_tag.json"
|
101
|
+
resp = { status: 200, body: body.to_json, headers: {} }
|
102
|
+
|
103
|
+
stub_request(:get, endpoint)
|
104
|
+
.with(:query => { tag_type => slug })
|
105
|
+
.to_return(resp)
|
106
|
+
|
107
|
+
if tag_type == "section"
|
108
|
+
stub_request(:get, endpoint)
|
109
|
+
.with(:query => { "tag" => slug })
|
110
|
+
.to_return(resp)
|
111
|
+
end
|
112
|
+
|
99
113
|
sort_orders = ["alphabetical", "curated"]
|
100
114
|
sort_orders.each do |order|
|
115
|
+
stub_request(:get, endpoint)
|
116
|
+
.with(:query => { tag_type => slug, "sort" => order })
|
117
|
+
.to_return(resp)
|
118
|
+
|
101
119
|
if tag_type == "section"
|
102
|
-
|
103
|
-
|
120
|
+
stub_request(:get, endpoint)
|
121
|
+
.with(:query => { "tag" => slug, "sort" => order })
|
122
|
+
.to_return(resp)
|
104
123
|
end
|
105
|
-
|
106
|
-
url = "#{CONTENT_API_ENDPOINT}/with_tag.json?sort=#{order}&#{CGI.escape(tag_type)}=#{CGI.escape(slug)}"
|
107
|
-
stub_request(:get, url).to_return(status: 200, body: body.to_json, headers: {})
|
108
124
|
end
|
109
125
|
end
|
110
126
|
|
127
|
+
def content_api_has_sorted_artefacts_with_a_tag(tag_type, slug, sort_order, artefact_slugs=[])
|
128
|
+
body = plural_response_base.merge(
|
129
|
+
"results" => artefact_slugs.map do |artefact_slug|
|
130
|
+
artefact_for_slug(artefact_slug)
|
131
|
+
end
|
132
|
+
)
|
133
|
+
|
134
|
+
endpoint = "#{CONTENT_API_ENDPOINT}/with_tag.json"
|
135
|
+
stub_request(:get, endpoint)
|
136
|
+
.with(:query => { tag_type => slug, "sort" => sort_order })
|
137
|
+
.to_return(status: 200, body: body.to_json, headers: {})
|
138
|
+
end
|
139
|
+
|
111
140
|
def content_api_has_an_artefact(slug, body = artefact_for_slug(slug))
|
112
141
|
ArtefactStub.new(slug).with_response_body(body).stub
|
113
142
|
end
|
data/lib/gds_api/version.rb
CHANGED
data/test/content_api_test.rb
CHANGED
@@ -310,13 +310,8 @@ describe GdsApi::ContentApi do
|
|
310
310
|
assert_equal "#{@base_api_url}/tags/genres/indie%2Findie-rock.json", first_section.id
|
311
311
|
end
|
312
312
|
|
313
|
-
it "
|
314
|
-
|
315
|
-
api_url = "#{@base_api_url}/with_tag.json?tag=#{tag}&include_children=1"
|
316
|
-
json = {
|
317
|
-
results: [{title: "Complain about a claims company"}]
|
318
|
-
}.to_json
|
319
|
-
stub_request(:get, api_url).to_return(:status => 200, :body => json)
|
313
|
+
it "returns artefacts given a section" do
|
314
|
+
content_api_has_artefacts_in_a_section("crime-and-justice", ["complain-about-a-claims-company"])
|
320
315
|
response = @api.with_tag("crime-and-justice")
|
321
316
|
|
322
317
|
# Old dictionary-style access
|
@@ -328,81 +323,52 @@ describe GdsApi::ContentApi do
|
|
328
323
|
end
|
329
324
|
|
330
325
|
it "returns artefacts given a tag and tag type" do
|
331
|
-
|
332
|
-
json = {
|
333
|
-
results: [{title: "Three Little Birds"}]
|
334
|
-
}
|
335
|
-
stub_request(:get, api_url).to_return(:status => 200, :body => json.to_json)
|
326
|
+
content_api_has_artefacts_with_a_tag("genre", "reggae", ["three-little-birds"])
|
336
327
|
response = @api.with_tag("reggae", "genre")
|
337
328
|
|
338
|
-
assert_equal "Three
|
329
|
+
assert_equal "Three little birds", response.first.title
|
339
330
|
end
|
340
331
|
|
341
|
-
it "
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
}
|
347
|
-
stub_request(:get, api_url).to_return(:status => 200, :body => json.to_json)
|
348
|
-
response = @api.tag(tag)
|
349
|
-
title = response['title']
|
350
|
-
assert_equal json[:title], title
|
332
|
+
it "returns tag information for a section" do
|
333
|
+
content_api_has_section("crime-and-justice")
|
334
|
+
response = @api.tag("crime-and-justice")
|
335
|
+
|
336
|
+
assert_equal "Crime and justice", response["title"]
|
351
337
|
end
|
352
338
|
|
353
|
-
it "returns tag information
|
354
|
-
|
355
|
-
json = {
|
356
|
-
title: "Reggae"
|
357
|
-
}
|
358
|
-
stub_request(:get, api_url).to_return(:status => 200, :body => json.to_json)
|
339
|
+
it "returns tag information for a tag and tag type" do
|
340
|
+
content_api_has_tag("genre", "reggae")
|
359
341
|
response = @api.tag("reggae", "genre")
|
360
342
|
|
361
343
|
assert_equal "Reggae", response['title']
|
362
344
|
end
|
363
345
|
|
364
|
-
it "returns artefacts
|
365
|
-
|
366
|
-
json = {
|
367
|
-
results: [{title: "Complain about a claims company"}]
|
368
|
-
}
|
369
|
-
stub_request(:get, api_url).to_return(:status => 200, :body => json.to_json)
|
346
|
+
it "returns artefacts in curated list order for a section" do
|
347
|
+
content_api_has_artefacts_in_a_section("crime-and-justice", ["complain-about-a-claims-company"])
|
370
348
|
response = @api.curated_list("crime-and-justice")
|
371
349
|
|
372
350
|
assert_equal "Complain about a claims company", response.first.title
|
373
351
|
end
|
374
352
|
|
375
353
|
it "returns artefacts in curated list order for a tag and tag type" do
|
376
|
-
|
377
|
-
json = {
|
378
|
-
results: [{title: "Buffalo Soldier"}]
|
379
|
-
}
|
380
|
-
stub_request(:get, api_url).to_return(:status => 200, :body => json.to_json)
|
354
|
+
content_api_has_artefacts_with_a_tag("genre", "reggae", ["buffalo-soldier"])
|
381
355
|
response = @api.curated_list("reggae", "genre")
|
382
356
|
|
383
|
-
assert_equal "Buffalo
|
357
|
+
assert_equal "Buffalo soldier", response.first.title
|
384
358
|
end
|
385
359
|
|
386
360
|
it "returns artefacts for a tag in a given sort order" do
|
387
|
-
|
388
|
-
|
389
|
-
results: [{title: "Complain about a claims company"}]
|
390
|
-
}
|
391
|
-
stub_request(:get, api_url).to_return(:status => 200, :body => json.to_json)
|
392
|
-
response = @api.sorted_by("crime-and-justice", "foo")
|
361
|
+
content_api_has_artefacts_in_a_section("crime-and-justice", ["complain-about-a-claims-company"])
|
362
|
+
response = @api.sorted_by("crime-and-justice", "alphabetical")
|
393
363
|
|
394
364
|
assert_equal "Complain about a claims company", response.first.title
|
395
365
|
end
|
396
366
|
|
397
367
|
it "returns artefacts in a given sort order for a tag and tag type" do
|
398
|
-
|
399
|
-
json = {
|
400
|
-
results: [{title: "Is This Love"}]
|
401
|
-
}
|
402
|
-
stub_request(:get, api_url).to_return(:status => 200, :body => json.to_json)
|
368
|
+
content_api_has_sorted_artefacts_with_a_tag("genre", "reggae", "foo", ["is-this-love"])
|
403
369
|
response = @api.sorted_by("reggae", "foo", "genre")
|
404
370
|
|
405
|
-
assert_equal "Is
|
371
|
+
assert_equal "Is this love", response.first.title
|
406
372
|
end
|
407
373
|
end
|
408
374
|
|
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: 8.2.
|
4
|
+
version: 8.2.3
|
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-01-
|
12
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: plek
|
@@ -364,7 +364,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
364
364
|
version: '0'
|
365
365
|
segments:
|
366
366
|
- 0
|
367
|
-
hash:
|
367
|
+
hash: 2889202299403789685
|
368
368
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
369
369
|
none: false
|
370
370
|
requirements:
|
@@ -373,7 +373,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
373
373
|
version: '0'
|
374
374
|
segments:
|
375
375
|
- 0
|
376
|
-
hash:
|
376
|
+
hash: 2889202299403789685
|
377
377
|
requirements: []
|
378
378
|
rubyforge_project:
|
379
379
|
rubygems_version: 1.8.23
|