gds-api-adapters 38.0.0 → 38.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +5 -5
  3. data/lib/gds_api/asset_manager.rb +7 -7
  4. data/lib/gds_api/base.rb +13 -11
  5. data/lib/gds_api/business_support_api.rb +3 -4
  6. data/lib/gds_api/content_api.rb +31 -44
  7. data/lib/gds_api/content_store.rb +2 -3
  8. data/lib/gds_api/email_alert_api.rb +6 -7
  9. data/lib/gds_api/exceptions.rb +4 -1
  10. data/lib/gds_api/gov_uk_delivery.rb +9 -8
  11. data/lib/gds_api/govuk_headers.rb +1 -1
  12. data/lib/gds_api/imminence.rb +9 -10
  13. data/lib/gds_api/json_client.rb +21 -34
  14. data/lib/gds_api/licence_application.rb +2 -2
  15. data/lib/gds_api/list_response.rb +7 -10
  16. data/lib/gds_api/local_links_manager.rb +1 -1
  17. data/lib/gds_api/mapit.rb +5 -6
  18. data/lib/gds_api/middleware/govuk_header_sniffer.rb +1 -1
  19. data/lib/gds_api/need_api.rb +7 -8
  20. data/lib/gds_api/null_cache.rb +2 -2
  21. data/lib/gds_api/organisations.rb +2 -2
  22. data/lib/gds_api/panopticon.rb +11 -11
  23. data/lib/gds_api/performance_platform/data_in.rb +4 -4
  24. data/lib/gds_api/performance_platform/data_out.rb +1 -1
  25. data/lib/gds_api/publishing_api.rb +4 -5
  26. data/lib/gds_api/publishing_api/special_route_publisher.rb +5 -3
  27. data/lib/gds_api/publishing_api_v2.rb +8 -16
  28. data/lib/gds_api/response.rb +2 -5
  29. data/lib/gds_api/router.rb +18 -9
  30. data/lib/gds_api/rummager.rb +6 -7
  31. data/lib/gds_api/support.rb +7 -6
  32. data/lib/gds_api/support_api.rb +14 -14
  33. data/lib/gds_api/test_helpers/asset_manager.rb +3 -6
  34. data/lib/gds_api/test_helpers/business_support_api.rb +4 -4
  35. data/lib/gds_api/test_helpers/business_support_helper.rb +9 -8
  36. data/lib/gds_api/test_helpers/common_responses.rb +10 -12
  37. data/lib/gds_api/test_helpers/content_api.rb +23 -23
  38. data/lib/gds_api/test_helpers/content_api/artefact_stub.rb +13 -12
  39. data/lib/gds_api/test_helpers/content_item_helpers.rb +4 -4
  40. data/lib/gds_api/test_helpers/content_store.rb +3 -3
  41. data/lib/gds_api/test_helpers/email_alert_api.rb +8 -10
  42. data/lib/gds_api/test_helpers/gov_uk_delivery.rb +0 -1
  43. data/lib/gds_api/test_helpers/imminence.rb +4 -4
  44. data/lib/gds_api/test_helpers/intent_helpers.rb +0 -2
  45. data/lib/gds_api/test_helpers/local_links_manager.rb +12 -13
  46. data/lib/gds_api/test_helpers/mapit.rb +14 -15
  47. data/lib/gds_api/test_helpers/need_api.rb +4 -4
  48. data/lib/gds_api/test_helpers/organisations.rb +13 -15
  49. data/lib/gds_api/test_helpers/panopticon.rb +6 -6
  50. data/lib/gds_api/test_helpers/performance_platform/data_in.rb +8 -8
  51. data/lib/gds_api/test_helpers/publishing_api.rb +19 -20
  52. data/lib/gds_api/test_helpers/publishing_api_v2.rb +13 -13
  53. data/lib/gds_api/test_helpers/router.rb +5 -5
  54. data/lib/gds_api/test_helpers/rummager.rb +5 -4
  55. data/lib/gds_api/test_helpers/support.rb +11 -11
  56. data/lib/gds_api/test_helpers/support_api.rb +14 -14
  57. data/lib/gds_api/test_helpers/whitehall_admin_api.rb +1 -1
  58. data/lib/gds_api/test_helpers/worldwide.rb +16 -19
  59. data/lib/gds_api/version.rb +1 -1
  60. data/lib/gds_api/worldwide.rb +4 -4
  61. data/test/asset_manager_test.rb +6 -6
  62. data/test/business_support_api_test.rb +9 -10
  63. data/test/content_api_test.rb +81 -83
  64. data/test/email_alert_api_test.rb +3 -5
  65. data/test/gds_api_base_test.rb +9 -10
  66. data/test/gov_uk_delivery_test.rb +4 -6
  67. data/test/imminence_api_test.rb +7 -9
  68. data/test/json_client_test.rb +71 -64
  69. data/test/licence_application_api_test.rb +5 -7
  70. data/test/list_response_test.rb +27 -32
  71. data/test/mapit_test.rb +7 -9
  72. data/test/middleware/govuk_header_sniffer_test.rb +1 -1
  73. data/test/need_api_test.rb +8 -8
  74. data/test/organisations_api_test.rb +2 -2
  75. data/test/panopticon_registerer_test.rb +10 -10
  76. data/test/panopticon_test.rb +5 -5
  77. data/test/pp_data_in_test.rb +3 -3
  78. data/test/publishing_api_test.rb +2 -6
  79. data/test/publishing_api_v2_test.rb +40 -50
  80. data/test/response_test.rb +21 -22
  81. data/test/router_test.rb +78 -80
  82. data/test/rummager_test.rb +14 -14
  83. data/test/support_api_test.rb +13 -13
  84. data/test/support_test.rb +15 -16
  85. data/test/test_helper.rb +1 -1
  86. data/test/test_helpers/email_alert_api_test.rb +3 -3
  87. data/test/test_helpers/pact_helper.rb +1 -1
  88. data/test/test_helpers/panopticon_test.rb +1 -1
  89. data/test/test_helpers/publishing_api_test.rb +7 -7
  90. data/test/test_helpers/publishing_api_v2_test.rb +5 -9
  91. data/test/worldwide_api_test.rb +3 -3
  92. metadata +2 -3
  93. data/lib/gds_api/core-ext/openstruct.rb +0 -5
@@ -15,27 +15,26 @@ describe GdsApi::BusinessSupportApi do
15
15
  it "should return all schemes when called with no facets" do
16
16
  business_support_api_has_schemes([:scheme1, :scheme2, :scheme3])
17
17
  response = @api.schemes
18
- assert_equal [{"title" => "scheme1"}, {"title" => "scheme2"}, {"title" => "scheme3"}], response['results']
18
+ assert_equal [{ "title" => "scheme1" }, { "title" => "scheme2" }, { "title" => "scheme3" }], response['results']
19
19
  end
20
- it "should return schemes for applicable facets" do
21
- business_support_api_has_scheme(:scottish_manufacturing, {locations: 'scotland', sectors: 'manufacturing', support_types: 'grant,loan'})
22
- response = @api.schemes({locations: 'scotland', sectors: 'manufacturing', support_types: 'grant,loan'})
20
+ it "should return schemes for applicable facets" do
21
+ business_support_api_has_scheme(:scottish_manufacturing, locations: 'scotland', sectors: 'manufacturing', support_types: 'grant,loan')
22
+ response = @api.schemes(locations: 'scotland', sectors: 'manufacturing', support_types: 'grant,loan')
23
23
  assert_equal 1, response["results"].size
24
24
  assert_equal "scottish_manufacturing", response["results"].first["title"]
25
25
  end
26
26
  it "should return an empty result when facets are not applicable" do
27
- business_support_api_has_scheme(:super_secret, {locations: 'the moon', sectors: 'espionage'})
28
- response = @api.schemes({locations: 'earth', sectors: 'espionage'})
27
+ business_support_api_has_scheme(:super_secret, locations: 'the moon', sectors: 'espionage')
28
+ response = @api.schemes(locations: 'earth', sectors: 'espionage')
29
29
  assert_empty response["results"]
30
30
  end
31
31
  end
32
32
 
33
33
  describe "finding a scheme by slug" do
34
34
  it "should give the scheme details" do
35
- business_support_api_has_a_scheme('superbiz-wunderfundz', {
36
- :title => 'Superbiz wunderfundz',
37
- :short_description => 'Wunderfundz for your superbiz',
38
- :body => 'Do you run or work for a Superbiz? Well we have the Wunderfundz.'})
35
+ business_support_api_has_a_scheme('superbiz-wunderfundz', title: 'Superbiz wunderfundz',
36
+ short_description: 'Wunderfundz for your superbiz',
37
+ body: 'Do you run or work for a Superbiz? Well we have the Wunderfundz.')
39
38
  response = @api.scheme('superbiz-wunderfundz')
40
39
  assert_equal 'business_support', response['format']
41
40
  assert_equal 'Superbiz wunderfundz', response['title']
@@ -132,7 +132,7 @@ describe GdsApi::ContentApi do
132
132
  stub_request(:get, url).to_return(
133
133
  status: 200,
134
134
  body: body.to_json,
135
- headers: {"Link" => links.join(",")}
135
+ headers: { "Link" => links.join(",") }
136
136
  )
137
137
  end
138
138
 
@@ -192,7 +192,7 @@ describe GdsApi::ContentApi do
192
192
  end
193
193
 
194
194
  it "should be able to fetch unpublished editions when authenticated" do
195
- api = GdsApi::ContentApi.new(@base_api_url, { bearer_token: 'MY_BEARER_TOKEN' })
195
+ api = GdsApi::ContentApi.new(@base_api_url, bearer_token: 'MY_BEARER_TOKEN')
196
196
  content_api_has_unpublished_artefact("devolution-uk", 3)
197
197
  response = api.artefact("devolution-uk", edition: 3)
198
198
  assert_equal "#{@base_api_url}/devolution-uk.json", response["id"]
@@ -227,14 +227,14 @@ describe GdsApi::ContentApi do
227
227
 
228
228
  it "should return a listresponse for the artefacts" do
229
229
  WebMock.stub_request(:get, @artefacts_endpoint).
230
- to_return(:body => {
231
- "_response_info" => {"status" => "ok"},
230
+ to_return(body: {
231
+ "_response_info" => { "status" => "ok" },
232
232
  "total" => 4,
233
233
  "results" => [
234
- {"format" => "answer", "web_url" => "http://www.test.gov.uk/foo"},
235
- {"format" => "local_transaction", "web_url" => "http://www.test.gov.uk/bar/baz"},
236
- {"format" => "place", "web_url" => "http://www.test.gov.uk/somewhere"},
237
- {"format" => "guide", "web_url" => "http://www.test.gov.uk/vat"},
234
+ { "format" => "answer", "web_url" => "http://www.test.gov.uk/foo" },
235
+ { "format" => "local_transaction", "web_url" => "http://www.test.gov.uk/bar/baz" },
236
+ { "format" => "place", "web_url" => "http://www.test.gov.uk/somewhere" },
237
+ { "format" => "guide", "web_url" => "http://www.test.gov.uk/vat" },
238
238
  ]
239
239
  }.to_json)
240
240
 
@@ -249,27 +249,27 @@ describe GdsApi::ContentApi do
249
249
  it "should work with a paginated response" do
250
250
  WebMock.stub_request(:get, @artefacts_endpoint).
251
251
  to_return(
252
- :body => {
253
- "_response_info" => {"status" => "ok"},
252
+ body: {
253
+ "_response_info" => { "status" => "ok" },
254
254
  "total" => 4,
255
255
  "results" => [
256
- {"format" => "answer", "web_url" => "http://www.test.gov.uk/foo"},
257
- {"format" => "local_transaction", "web_url" => "http://www.test.gov.uk/bar/baz"},
258
- {"format" => "place", "web_url" => "http://www.test.gov.uk/somewhere"},
259
- {"format" => "guide", "web_url" => "http://www.test.gov.uk/vat"},
256
+ { "format" => "answer", "web_url" => "http://www.test.gov.uk/foo" },
257
+ { "format" => "local_transaction", "web_url" => "http://www.test.gov.uk/bar/baz" },
258
+ { "format" => "place", "web_url" => "http://www.test.gov.uk/somewhere" },
259
+ { "format" => "guide", "web_url" => "http://www.test.gov.uk/vat" },
260
260
  ]
261
261
  }.to_json,
262
- :headers => {"Link" => "<#{@artefacts_endpoint}?page=2>; rel=\"next\""}
262
+ headers: { "Link" => "<#{@artefacts_endpoint}?page=2>; rel=\"next\"" }
263
263
  )
264
264
  WebMock.stub_request(:get, "#{@artefacts_endpoint}?page=2").
265
265
  to_return(
266
- :body => {
267
- "_response_info" => {"status" => "ok"},
266
+ body: {
267
+ "_response_info" => { "status" => "ok" },
268
268
  "total" => 3,
269
269
  "results" => [
270
- {"format" => "answer", "web_url" => "http://www.test.gov.uk/foo2"},
271
- {"format" => "local_transaction", "web_url" => "http://www.test.gov.uk/bar/baz2"},
272
- {"format" => "guide", "web_url" => "http://www.test.gov.uk/vat2"},
270
+ { "format" => "answer", "web_url" => "http://www.test.gov.uk/foo2" },
271
+ { "format" => "local_transaction", "web_url" => "http://www.test.gov.uk/bar/baz2" },
272
+ { "format" => "guide", "web_url" => "http://www.test.gov.uk/vat2" },
273
273
  ]
274
274
  }.to_json
275
275
  )
@@ -425,28 +425,26 @@ describe GdsApi::ContentApi do
425
425
 
426
426
  describe "licence" do
427
427
  it "should return an artefact with licence for a snac code" do
428
- response = content_api_has_an_artefact_with_snac_code("licence-example", '1234', {
429
- "title" => "Licence Example",
428
+ content_api_has_an_artefact_with_snac_code("licence-example", '1234', "title" => "Licence Example",
430
429
  "slug" => "licence-example",
431
430
  "details" => {
432
431
  "licence" => {
433
432
  "location_specific" => false,
434
- "availability" => [ "England", "Wales" ],
435
- "authorities" => [ ]
433
+ "availability" => %w(England Wales),
434
+ "authorities" => []
436
435
  }
437
- }
438
- })
436
+ })
439
437
  response = @api.artefact('licence-example', snac: '1234')
440
438
 
441
439
  assert_equal "Licence Example", response["title"]
442
- assert_equal [ "England", "Wales" ], response["details"]["licence"]["availability"]
440
+ assert_equal %w(England Wales), response["details"]["licence"]["availability"]
443
441
  end
444
442
 
445
443
  it "should escape snac code when searching for licence" do
446
444
  stub_request(:get, "#{@base_api_url}/licence-example.json?snac=snacks%21").
447
- to_return(:status => 200,
448
- :body => {"test" => "ing"}.to_json,
449
- :headers => {})
445
+ to_return(status: 200,
446
+ body: { "test" => "ing" }.to_json,
447
+ headers: {})
450
448
 
451
449
  @api.artefact("licence-example", snac: "snacks!")
452
450
 
@@ -458,7 +456,7 @@ describe GdsApi::ContentApi do
458
456
  url = "#{@base_api_url}/licence-example.json?snac=1234&edition=1"
459
457
  stub_request(:get, url).to_return(status: 200, body: body.to_json)
460
458
 
461
- api = GdsApi::ContentApi.new(@base_api_url, { bearer_token: 'MY_BEARER_TOKEN' })
459
+ api = GdsApi::ContentApi.new(@base_api_url, bearer_token: 'MY_BEARER_TOKEN')
462
460
  response = api.artefact('licence-example', snac: '1234', edition: '1')
463
461
 
464
462
  assert_equal "Licence example", response["title"]
@@ -468,10 +466,10 @@ describe GdsApi::ContentApi do
468
466
  describe "local authorities" do
469
467
  it "should raise if no local authority found" do
470
468
  stub_request(:get, "#{@base_api_url}/local_authorities/does-not-exist.json").
471
- with(:headers => GdsApi::JsonClient.default_request_headers).
472
- to_return(:status => 404,
473
- :body => {"_response_info" => {"status" => "ok"}}.to_json,
474
- :headers => {})
469
+ with(headers: GdsApi::JsonClient.default_request_headers).
470
+ to_return(status: 404,
471
+ body: { "_response_info" => { "status" => "ok" } }.to_json,
472
+ headers: {})
475
473
 
476
474
  assert_raises(GdsApi::HTTPNotFound) do
477
475
  @api.local_authority("does-not-exist")
@@ -483,14 +481,14 @@ describe GdsApi::ContentApi do
483
481
  "name" => "Solihull Metropolitan Borough Council",
484
482
  "snac_code" => "00CT",
485
483
  "id" => "#{@base_api_url}/local_authorities/00CT.json",
486
- "_response_info" => {"status" => "ok"}
484
+ "_response_info" => { "status" => "ok" }
487
485
  }
488
486
 
489
487
  stub_request(:get, "#{@base_api_url}/local_authorities/00CT.json").
490
- with(:headers => GdsApi::JsonClient.default_request_headers).
491
- to_return(:status => 200,
492
- :body => body_response.to_json,
493
- :headers => {})
488
+ with(headers: GdsApi::JsonClient.default_request_headers).
489
+ to_return(status: 200,
490
+ body: body_response.to_json,
491
+ headers: {})
494
492
 
495
493
  response = @api.local_authority("00CT").to_hash
496
494
 
@@ -499,17 +497,17 @@ describe GdsApi::ContentApi do
499
497
 
500
498
  it "should return an empty result set if name not found" do
501
499
  body_response = {
502
- "_response_info" => {"status" => "ok"},
500
+ "_response_info" => { "status" => "ok" },
503
501
  "description" => "Local Authorities",
504
502
  "total" => 0,
505
503
  "results" => []
506
504
  }.to_json
507
505
 
508
506
  stub_request(:get, "#{@base_api_url}/local_authorities.json?name=Swansalona").
509
- with(:headers => GdsApi::JsonClient.default_request_headers).
510
- to_return(:status => 200,
511
- :body => body_response,
512
- :headers => {})
507
+ with(headers: GdsApi::JsonClient.default_request_headers).
508
+ to_return(status: 200,
509
+ body: body_response,
510
+ headers: {})
513
511
 
514
512
  response = @api.local_authorities_by_name("Swansalona")
515
513
 
@@ -519,17 +517,17 @@ describe GdsApi::ContentApi do
519
517
 
520
518
  it "should return an empty result set if snac code not found" do
521
519
  body_response = {
522
- "_response_info" => {"status" => "ok"},
520
+ "_response_info" => { "status" => "ok" },
523
521
  "description" => "Local Authorities",
524
522
  "total" => 0,
525
523
  "results" => []
526
524
  }.to_json
527
525
 
528
526
  stub_request(:get, "#{@base_api_url}/local_authorities.json?snac_code=SNACKS").
529
- with(:headers => GdsApi::JsonClient.default_request_headers).
530
- to_return(:status => 200,
531
- :body => body_response,
532
- :headers => {})
527
+ with(headers: GdsApi::JsonClient.default_request_headers).
528
+ to_return(status: 200,
529
+ body: body_response,
530
+ headers: {})
533
531
 
534
532
  response = @api.local_authorities_by_snac_code("SNACKS")
535
533
 
@@ -539,7 +537,7 @@ describe GdsApi::ContentApi do
539
537
 
540
538
  it "should have an array of results for a name search" do
541
539
  body_response = {
542
- "_response_info" => {"status" => "ok"},
540
+ "_response_info" => { "status" => "ok" },
543
541
  "description" => "Local Authorities",
544
542
  "total" => 2,
545
543
  "results" => [{
@@ -555,10 +553,10 @@ describe GdsApi::ContentApi do
555
553
  }.to_json
556
554
 
557
555
  stub_request(:get, "#{@base_api_url}/local_authorities.json?name=Swans").
558
- with(:headers => GdsApi::JsonClient.default_request_headers).
559
- to_return(:status => 200,
560
- :body => body_response,
561
- :headers => {})
556
+ with(headers: GdsApi::JsonClient.default_request_headers).
557
+ to_return(status: 200,
558
+ body: body_response,
559
+ headers: {})
562
560
 
563
561
  response = @api.local_authorities_by_name("Swans")
564
562
 
@@ -568,9 +566,9 @@ describe GdsApi::ContentApi do
568
566
 
569
567
  it "should escape snac code when calling unique a local authority" do
570
568
  stub_request(:get, "#{@base_api_url}/local_authorities/escape%21.json").
571
- to_return(:status => 200,
572
- :body => {"test" => "ing"}.to_json,
573
- :headers => {})
569
+ to_return(status: 200,
570
+ body: { "test" => "ing" }.to_json,
571
+ headers: {})
574
572
 
575
573
  @api.local_authority("escape!")
576
574
 
@@ -579,9 +577,9 @@ describe GdsApi::ContentApi do
579
577
 
580
578
  it "should escape name when searching for local authorities" do
581
579
  stub_request(:get, "#{@base_api_url}/local_authorities.json?name=name%21").
582
- to_return(:status => 200,
583
- :body => {"test" => "ing"}.to_json,
584
- :headers => {})
580
+ to_return(status: 200,
581
+ body: { "test" => "ing" }.to_json,
582
+ headers: {})
585
583
 
586
584
  @api.local_authorities_by_name("name!")
587
585
 
@@ -590,9 +588,9 @@ describe GdsApi::ContentApi do
590
588
 
591
589
  it "should escape snac code when searching for local authorities" do
592
590
  stub_request(:get, "#{@base_api_url}/local_authorities.json?snac_code=snacks%21").
593
- to_return(:status => 200,
594
- :body => {"test" => "ing"}.to_json,
595
- :headers => {})
591
+ to_return(status: 200,
592
+ body: { "test" => "ing" }.to_json,
593
+ headers: {})
596
594
 
597
595
  @api.local_authorities_by_snac_code("snacks!")
598
596
 
@@ -603,29 +601,29 @@ describe GdsApi::ContentApi do
603
601
  describe "business support schemes" do
604
602
  it "should query content_api for business_support_schemes" do
605
603
  stub_request(:get, %r{\A#{@base_api_url}/business_support_schemes.json}).
606
- to_return(:status => 200, :body => {"foo" => "bar"}.to_json)
604
+ to_return(status: 200, body: { "foo" => "bar" }.to_json)
607
605
 
608
- response = @api.business_support_schemes(:drink => "coffee")
606
+ response = @api.business_support_schemes(drink: "coffee")
609
607
 
610
- assert_equal({"foo" => "bar"}, response.to_hash)
611
- assert_requested :get, "#{@base_api_url}/business_support_schemes.json?drink=coffee", :times => 1
608
+ assert_equal({ "foo" => "bar" }, response.to_hash)
609
+ assert_requested :get, "#{@base_api_url}/business_support_schemes.json?drink=coffee", times: 1
612
610
  end
613
611
 
614
612
  it "should raise an error if content_api returns 404" do
615
613
  stub_request(:get, %r{\A#{@base_api_url}/business_support_schemes.json}).
616
- to_return(:status => 404, :body => "Not Found")
614
+ to_return(status: 404, body: "Not Found")
617
615
 
618
616
  assert_raises GdsApi::HTTPNotFound do
619
- @api.business_support_schemes(['foo', 'bar'])
617
+ @api.business_support_schemes(%w(foo bar))
620
618
  end
621
619
  end
622
620
 
623
621
  it "should raise an error if content_api returns a 50x error" do
624
622
  stub_request(:get, %r{\A#{@base_api_url}/business_support_schemes.json}).
625
- to_return(:status => 503, :body => "Gateway timeout")
623
+ to_return(status: 503, body: "Gateway timeout")
626
624
 
627
625
  assert_raises GdsApi::HTTPServerError do
628
- @api.business_support_schemes(['foo', 'bar'])
626
+ @api.business_support_schemes(%w(foo bar))
629
627
  end
630
628
  end
631
629
 
@@ -633,13 +631,13 @@ describe GdsApi::ContentApi do
633
631
  it "should have representative test helpers" do
634
632
  setup_content_api_business_support_schemes_stubs
635
633
  s1 = { "title" => "Scheme 1", "format" => "business_support" }
636
- content_api_has_business_support_scheme(s1, :locations => "england", :sectors => "farming")
634
+ content_api_has_business_support_scheme(s1, locations: "england", sectors: "farming")
637
635
  s2 = { "title" => "Scheme 2", "format" => "business_support" }
638
- content_api_has_business_support_scheme(s2, :sectors => "farming")
636
+ content_api_has_business_support_scheme(s2, sectors: "farming")
639
637
  s3 = { "title" => "Scheme 3", "format" => "business_support" }
640
- content_api_has_business_support_scheme(s3, :locations => "england", :sectors => "farming")
638
+ content_api_has_business_support_scheme(s3, locations: "england", sectors: "farming")
641
639
 
642
- response = @api.business_support_schemes(:locations => "england", :sectors => "farming").to_hash
640
+ response = @api.business_support_schemes(locations: "england", sectors: "farming").to_hash
643
641
 
644
642
  assert_equal 2, response["total"]
645
643
  assert_equal s1["title"], response["results"].first["title"]
@@ -652,12 +650,12 @@ describe GdsApi::ContentApi do
652
650
  it "should get licence details" do
653
651
  setup_content_api_licences_stubs
654
652
 
655
- content_api_has_licence :licence_identifier => "1234", :title => 'Test Licence 1', :slug => 'test-licence-1',
656
- :licence_short_description => 'A short description'
657
- content_api_has_licence :licence_identifier => "1235", :title => 'Test Licence 2', :slug => 'test-licence-2',
658
- :licence_short_description => 'A short description'
659
- content_api_has_licence :licence_identifier => "AB1234", :title => 'Test Licence 3', :slug => 'test-licence-3',
660
- :licence_short_description => 'A short description'
653
+ content_api_has_licence licence_identifier: "1234", title: 'Test Licence 1', slug: 'test-licence-1',
654
+ licence_short_description: 'A short description'
655
+ content_api_has_licence licence_identifier: "1235", title: 'Test Licence 2', slug: 'test-licence-2',
656
+ licence_short_description: 'A short description'
657
+ content_api_has_licence licence_identifier: "AB1234", title: 'Test Licence 3', slug: 'test-licence-3',
658
+ licence_short_description: 'A short description'
661
659
 
662
660
  results = @api.licences_for_ids([1234, 'AB1234', 'something'])['results']
663
661
  assert_equal 2, results.size
@@ -694,7 +692,7 @@ describe GdsApi::ContentApi do
694
692
 
695
693
  it "should raise an error if publisher returns an error" do
696
694
  stub_request(:get, %r[\A#{@base_api_url}/licences]).
697
- to_return(:status => [503, "Service temporarily unabailable"])
695
+ to_return(status: [503, "Service temporarily unabailable"])
698
696
 
699
697
  assert_raises GdsApi::HTTPServerError do
700
698
  @api.licences_for_ids([123, 124])
@@ -162,7 +162,7 @@ describe GdsApi::EmailAlertApi do
162
162
  describe "notifications" do
163
163
  it "retrieves notifications" do
164
164
  stubbed_request = email_alert_api_has_notifications([
165
- {"subject" => "Foo"}, {"subject" => "Bar"}
165
+ { "subject" => "Foo" }, { "subject" => "Bar" }
166
166
  ])
167
167
  api_client.notifications
168
168
  assert_requested(stubbed_request)
@@ -170,7 +170,7 @@ describe GdsApi::EmailAlertApi do
170
170
 
171
171
  it "uses the start_at param if present" do
172
172
  stubbed_request = email_alert_api_has_notifications([
173
- {"subject" => "Foo"}, {"subject" => "Bar"}
173
+ { "subject" => "Foo" }, { "subject" => "Bar" }
174
174
  ], "101AA")
175
175
  api_client.notifications("101AA")
176
176
  assert_requested(stubbed_request)
@@ -179,9 +179,7 @@ describe GdsApi::EmailAlertApi do
179
179
 
180
180
  describe "notification" do
181
181
  before do
182
- @stubbed_request = email_alert_api_has_notification({
183
- "web_service_bulletin" => { "to_param" => "10001001" }
184
- })
182
+ @stubbed_request = email_alert_api_has_notification("web_service_bulletin" => { "to_param" => "10001001" })
185
183
  end
186
184
  it "retrieves a notification by id" do
187
185
  api_client.notification("10001001")
@@ -3,7 +3,6 @@ require 'gds_api/base'
3
3
  require 'uri'
4
4
 
5
5
  class GdsApiBaseTest < Minitest::Test
6
-
7
6
  class ConcreteApi < GdsApi::Base
8
7
  def base_url
9
8
  endpoint
@@ -33,7 +32,7 @@ class GdsApiBaseTest < Minitest::Test
33
32
  u = URI.parse(url)
34
33
  assert_equal "b%5B%5D=123", u.query
35
34
 
36
- url = api.url_for_slug("slug", "b" => ['123', '456'])
35
+ url = api.url_for_slug("slug", "b" => %w(123 456))
37
36
  u = URI.parse(url)
38
37
  assert_equal "b%5B%5D=123&b%5B%5D=456", u.query
39
38
  end
@@ -41,30 +40,30 @@ class GdsApiBaseTest < Minitest::Test
41
40
  def test_should_not_add_a_question_mark_if_there_are_no_parameters
42
41
  api = ConcreteApi.new('http://foo')
43
42
  url = api.url_for_slug("slug")
44
- refute_match /\?/, url
43
+ refute_match(/\?/, url)
45
44
  end
46
45
 
47
46
  def test_should_use_endpoint_in_url
48
47
  api = ConcreteApi.new("http://foobarbaz")
49
48
  url = api.url_for_slug("slug")
50
49
  u = URI.parse(url)
51
- assert_match /foobarbaz$/, u.host
50
+ assert_match(/foobarbaz$/, u.host)
52
51
  end
53
52
 
54
53
  def test_should_accept_options_as_second_arg
55
- api = ConcreteApi.new("http://foo", {foo: "bar"})
54
+ api = ConcreteApi.new("http://foo", foo: "bar")
56
55
  assert_equal "bar", api.options[:foo]
57
56
  end
58
57
 
59
58
  def test_setting_cache_size_from_options
60
59
  GdsApi::JsonClient.cache = false
61
- api = ConcreteApi.new("https://foo", {cache_size: 2})
60
+ api = ConcreteApi.new("https://foo", cache_size: 2)
62
61
  assert_equal 2, api.client.cache.max_size
63
62
  end
64
63
 
65
64
  def test_setting_cache_size_from_default_options
66
65
  GdsApi::JsonClient.cache = false
67
- GdsApi::Base.default_options = {cache_size: 4}
66
+ GdsApi::Base.default_options = { cache_size: 4 }
68
67
  api = ConcreteApi.new("http://bar")
69
68
  assert_equal 4, api.client.cache.max_size
70
69
  end
@@ -83,10 +82,10 @@ class GdsApiBaseTest < Minitest::Test
83
82
  assert api.client.cache.is_a? GdsApi::NullCache
84
83
  end
85
84
 
86
- def test_should_barf_if_not_given_valid_URL
87
- proc do
85
+ def test_should_barf_if_not_given_valid_url
86
+ assert_raises GdsApi::Base::InvalidAPIURL do
88
87
  ConcreteApi.new('invalid-url')
89
- end.must_raise GdsApi::Base::InvalidAPIURL
88
+ end
90
89
  end
91
90
 
92
91
  def test_should_set_json_client_logger_to_own_logger_by_default