gds-api-adapters 4.3.0 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -93,6 +93,10 @@ class GdsApi::ContentApi < GdsApi::Base
93
93
  get_json(url) { |r| ListResponse.new(r, self) }
94
94
  end
95
95
 
96
+ def countries
97
+ get_json!("#{base_url}/travel-advice.json")
98
+ end
99
+
96
100
  private
97
101
  def base_url
98
102
  endpoint
@@ -300,6 +300,22 @@ module GdsApi
300
300
  @stubbed_content_api_licences << details
301
301
  end
302
302
 
303
+ def content_api_has_countries(countries)
304
+ response = response_base.merge({
305
+ "results" => countries.map {|id,name|
306
+ {
307
+ "id" => "#{CONTENT_API_ENDPOINT}/travel-advice/#{id}.json",
308
+ "name" => name,
309
+ "identifier" => id,
310
+ "web_url" => "http://www.test.gov.uk/travel-advice/#{id}"
311
+ }
312
+ },
313
+ "total" => countries.length
314
+ })
315
+
316
+ stub_request(:get, %r{\A#{CONTENT_API_ENDPOINT}/travel-advice\.json}).to_return(status: 200, body: response.to_json, headers: { })
317
+ end
318
+
303
319
  private
304
320
 
305
321
  def titleize_slug(slug)
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '4.3.0'
2
+ VERSION = '4.4.0'
3
3
  end
@@ -492,6 +492,23 @@ describe GdsApi::ContentApi do
492
492
  end
493
493
  end
494
494
 
495
+ it "should fetch the list of countries" do
496
+ content_api_has_countries({
497
+ 'afghanistan' => 'Afghanistan',
498
+ 'albania' => 'Albania',
499
+ 'algeria' => 'Algeria'
500
+ })
501
+
502
+ results = @api.countries['results']
503
+ assert_equal 3, results.length
504
+
505
+ assert_equal ['afghanistan', 'albania', 'algeria'], results.map {|c| c['identifier'] }
506
+ assert_equal ['Afghanistan', 'Albania', 'Algeria'], results.map {|c| c['name'] }
507
+
508
+ assert_equal "#{@base_api_url}/travel-advice/afghanistan.json", results.first['id']
509
+ assert_equal 'http://www.test.gov.uk/travel-advice/afghanistan', results.first['web_url']
510
+ end
511
+
495
512
  def api_response_for_results(results)
496
513
  {
497
514
  "_response_info" => {
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 4.3.0
5
+ version: 4.4.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Stewart
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2013-01-29 00:00:00 Z
13
+ date: 2013-02-04 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: plek
@@ -236,7 +236,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
236
236
  requirements:
237
237
  - - ">="
238
238
  - !ruby/object:Gem::Version
239
- hash: 4441910162548111668
239
+ hash: 355718895235244126
240
240
  segments:
241
241
  - 0
242
242
  version: "0"
@@ -245,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
245
  requirements:
246
246
  - - ">="
247
247
  - !ruby/object:Gem::Version
248
- hash: 4441910162548111668
248
+ hash: 355718895235244126
249
249
  segments:
250
250
  - 0
251
251
  version: "0"