gds-api-adapters 24.5.0 → 24.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1cdf38f1b222c05d8d81625b25b222de03f6f273
4
- data.tar.gz: 41fb59bce925ffd63f782566ccb50beda983bf8f
3
+ metadata.gz: 212e116b422961283b637ba076848769be4c2eaa
4
+ data.tar.gz: c79059c7b2f7040590283f54ff51950db3b401cb
5
5
  SHA512:
6
- metadata.gz: 2a57d45ce36edc708d49082e6fc47a66094e1d6717cfb71b24acd142cd7c996188cf1c2d3b7c109284720fd14fe459e405b54e48f5d0ccf8b4a61264642ef1ff
7
- data.tar.gz: 82494aeda400c32f9bdf66541d52c9e9a78a552dcd3ac606621e02f957ef92b5cdc08e55932dc97622cc8b15030d52e542165fd8985c82238183b7bfe4019032
6
+ metadata.gz: 982d5e547eec900056a748469da51fe2be0f62c831eb90074f56dfb748d8aa8a624e7af3b30b0c7996c61d52cfbb1c9db68ce9e350c8e3bbc1f8696f988c3897
7
+ data.tar.gz: 88442f8971daf8150de2328246199d0f1ee89e020a97f4443cb180a0da95d2f94af65783468420f7f005c5921d10faaaa51a2945780fc254d4adaa9cbefd5fd9
@@ -31,12 +31,6 @@ class GdsApi::Imminence < GdsApi::Base
31
31
  get_raw("#{@endpoint}/places/#{type}.kml").body
32
32
  end
33
33
 
34
- def business_support_schemes(facets_hash)
35
- query = facets_hash.keys.sort.map { |k| "#{k.to_s}=#{facets_hash[k]}" }.join("&")
36
- query = "?#{query}" unless query.empty?
37
- get_json!("#{@endpoint}/business_support_schemes.json#{query}")
38
- end
39
-
40
34
  def areas_for_postcode(postcode)
41
35
  url = "#{@endpoint}/areas/#{URI.encode(postcode)}.json"
42
36
  get_json(url)
@@ -70,5 +64,4 @@ private
70
64
  {"address" => address_fields.map(&:strip).join(", ")}
71
65
  end
72
66
 
73
-
74
67
  end
@@ -33,7 +33,7 @@ class GdsApi::Router < GdsApi::Base
33
33
 
34
34
  def add_redirect_route(path, type, destination, redirect_type = "permanent", options = {})
35
35
  response = put_json!("#{endpoint}/routes", :route => {:incoming_path => path, :route_type => type, :handler => "redirect",
36
- :redirect_to => destination, :redirect_type => redirect_type})
36
+ :redirect_to => destination, :redirect_type => redirect_type, :segments_mode => options[:segments_mode]})
37
37
  commit_routes if options[:commit]
38
38
  response
39
39
  end
@@ -15,33 +15,6 @@ module GdsApi
15
15
  to_return(:status => 200, :body => response, :headers => {})
16
16
  end
17
17
 
18
- def imminence_has_business_support_schemes(facets_hash, schemes)
19
- results = {
20
- "_response_info" => {"status" => "ok"},
21
- "description" => "Business Support Schemes!",
22
- "total" => schemes.size, "startIndex" => 1, "pageSize" => schemes.size, "currentPage" => 1, "pages" => 1,
23
- "results" => schemes
24
- }
25
-
26
- stub_request(:get, "#{IMMINENCE_API_ENDPOINT}/business_support_schemes.json").
27
- with(query: facets_hash).
28
- to_return(status: 200, body: results.to_json, headers: {})
29
- end
30
-
31
- # Stubs out all bussiness_support_schemes requests to return an ampty set of results.
32
- # Requests stubbed with the above method will take precedence over this.
33
- def stub_imminence_default_business_support_schemes
34
- empty_results = {
35
- "_response_info" => {"status" => "ok"},
36
- "description" => "Business Support Schemes!",
37
- "total" => 0, "startIndex" => 1, "pageSize" => 0, "currentPage" => 1, "pages" => 1,
38
- "results" => []
39
- }
40
-
41
- stub_request(:get, %r{\A#{IMMINENCE_API_ENDPOINT}/business_support_schemes\.json}).
42
- to_return(:body => empty_results.to_json)
43
- end
44
-
45
18
  def imminence_has_areas_for_postcode(postcode, areas)
46
19
  results = {
47
20
  "_response_info" => {"status" => "ok"},
@@ -31,13 +31,14 @@ module GdsApi
31
31
  [register_stub, commit_stub]
32
32
  end
33
33
 
34
- def stub_redirect_registration(path, type, destination, redirect_type)
34
+ def stub_redirect_registration(path, type, destination, redirect_type, segments_mode = nil)
35
35
  redirect = { route: {
36
36
  incoming_path: path,
37
37
  route_type: type,
38
38
  handler: 'redirect',
39
39
  redirect_to: destination,
40
- redirect_type: redirect_type }
40
+ redirect_type: redirect_type,
41
+ segments_mode: segments_mode }
41
42
  }
42
43
 
43
44
  register_stub = stub_route_put(redirect)
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '24.5.0'
2
+ VERSION = '24.6.0'
3
3
  end
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
  require 'gds_api/base'
3
3
  require 'uri'
4
4
 
5
- class GdsApiBaseTest < MiniTest::Unit::TestCase
5
+ class GdsApiBaseTest < Minitest::Test
6
6
 
7
7
  class ConcreteApi < GdsApi::Base
8
8
  def base_url
@@ -1,7 +1,7 @@
1
1
  require "test_helper"
2
2
  require "gds_api/imminence"
3
3
 
4
- class ImminenceApiTest < MiniTest::Unit::TestCase
4
+ class ImminenceApiTest < Minitest::Test
5
5
 
6
6
  ROOT = "https://imminence.test.alphagov.co.uk"
7
7
  LATITUDE = 52.1327584352089
@@ -118,25 +118,6 @@ class ImminenceApiTest < MiniTest::Unit::TestCase
118
118
  end
119
119
  end
120
120
 
121
- def test_business_support_schemes
122
- dummy_schemes = [
123
- { "business_support_identifier" => "bar-business-award", "title" => "Bar business award." },
124
- { "business_support_identifier" => "bar-small-business-loan", "title" => "Bar small business loan." },
125
- { "business_support_identifier" => "foo-small-business-loan", "title" => "Foo small business loan." }
126
- ]
127
- c = api_client
128
- url = "#{ROOT}/business_support_schemes.json?business_types=private-company&" +
129
- "sectors=agriculture,healthcare,manufacturing&stages=grow-and-sustain&types=award,loan"
130
- c.expects(:get_json!).with(url).returns(dummy_schemes)
131
-
132
- schemes = c.business_support_schemes(sectors: "agriculture,healthcare,manufacturing",
133
- business_types: "private-company", stages: "grow-and-sustain", types: "award,loan")
134
-
135
- assert_equal 3, schemes.size
136
- assert_equal "bar-business-award", schemes.first["business_support_identifier"]
137
- assert_equal "Foo small business loan.", schemes.last["title"]
138
- end
139
-
140
121
  def test_places_kml
141
122
  kml_body = <<-EOS
142
123
  <?xml version="1.0" encoding="UTF-8"?>
@@ -2,7 +2,7 @@ require "test_helper"
2
2
  require "gds_api/licence_application"
3
3
  require "gds_api/test_helpers/licence_application"
4
4
 
5
- class LicenceApplicationApiTest < MiniTest::Unit::TestCase
5
+ class LicenceApplicationApiTest < Minitest::Test
6
6
  include GdsApi::TestHelpers::LicenceApplication
7
7
 
8
8
  def setup
data/test/router_test.rb CHANGED
@@ -238,7 +238,8 @@ describe GdsApi::Router do
238
238
 
239
239
  describe "creating/updating a redirect route" do
240
240
  it "should allow creating/updating a redirect route" do
241
- route_data = {"incoming_path" => "/foo", "route_type" => "exact", "handler" => "redirect", "redirect_to" => "/bar", "redirect_type" => "permanent"}
241
+ route_data = {"incoming_path" => "/foo", "route_type" => "exact", "handler" => "redirect",
242
+ "redirect_to" => "/bar", "redirect_type" => "permanent", "segments_mode" => nil}
242
243
  req = WebMock.stub_request(:put, "#{@base_api_url}/routes").
243
244
  with(:body => {"route" => route_data}.to_json).
244
245
  to_return(:status => 201, :body => route_data.to_json, :headers => {"Content-type" => "application/json"})
@@ -252,7 +253,8 @@ describe GdsApi::Router do
252
253
  end
253
254
 
254
255
  it "should allow creating/updating a temporary redirect route" do
255
- route_data = {"incoming_path" => "/foo", "route_type" => "exact", "handler" => "redirect", "redirect_to" => "/bar", "redirect_type" => "temporary"}
256
+ route_data = {"incoming_path" => "/foo", "route_type" => "exact", "handler" => "redirect",
257
+ "redirect_to" => "/bar", "redirect_type" => "temporary", "segments_mode" => nil}
256
258
  req = WebMock.stub_request(:put, "#{@base_api_url}/routes").
257
259
  with(:body => {"route" => route_data}.to_json).
258
260
  to_return(:status => 201, :body => route_data.to_json, :headers => {"Content-type" => "application/json"})
@@ -265,6 +267,21 @@ describe GdsApi::Router do
265
267
  assert_not_requested(@commit_req)
266
268
  end
267
269
 
270
+ it "should allow creating/updating a redirect route which preserves segments" do
271
+ route_data = {"incoming_path" => "/foo", "route_type" => "exact", "handler" => "redirect",
272
+ "redirect_to" => "/bar", "redirect_type" => "temporary", "segments_mode" => "preserve"}
273
+ req = WebMock.stub_request(:put, "#{@base_api_url}/routes").
274
+ with(:body => {"route" => route_data}.to_json).
275
+ to_return(:status => 201, :body => route_data.to_json, :headers => {"Content-type" => "application/json"})
276
+
277
+ response = @api.add_redirect_route("/foo", "exact", "/bar", "temporary", :segments_mode => "preserve")
278
+ assert_equal 201, response.code
279
+ assert_equal "/bar", response.redirect_to
280
+
281
+ assert_requested(req)
282
+ assert_not_requested(@commit_req)
283
+ end
284
+
268
285
  it "should commit the routes when asked to" do
269
286
  req = WebMock.stub_request(:put, "#{@base_api_url}/routes").
270
287
  to_return(:status => 201, :body =>{}.to_json, :headers => {"Content-type" => "application/json"})
@@ -276,7 +293,8 @@ describe GdsApi::Router do
276
293
  end
277
294
 
278
295
  it "should raise an error if creating/updating the redirect route fails" do
279
- route_data = {"incoming_path" => "/foo", "route_type" => "exact", "handler" => "redirect", "redirect_to" => "bar", "redirect_type" => "permanent"}
296
+ route_data = {"incoming_path" => "/foo", "route_type" => "exact", "handler" => "redirect",
297
+ "redirect_to" => "bar", "redirect_type" => "permanent", "segments_mode" => nil}
280
298
  response_data = route_data.merge("errors" => {"redirect_to" => "is not a valid URL path"})
281
299
 
282
300
  req = WebMock.stub_request(:put, "#{@base_api_url}/routes").
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
  require 'gds_api/rummager'
3
3
  require 'gds_api/test_helpers/rummager'
4
4
 
5
- class RummagerHelpersTest < MiniTest::Unit::TestCase
5
+ class RummagerHelpersTest < Minitest::Test
6
6
  include GdsApi::TestHelpers::Rummager
7
7
 
8
8
  def test_services_and_info_data_returns_an_adequate_response_object
data/test/test_helper.rb CHANGED
@@ -20,7 +20,7 @@ SimpleCov.start do
20
20
  formatter SimpleCov::Formatter::RcovFormatter
21
21
  end
22
22
 
23
- class MiniTest::Unit::TestCase
23
+ class Minitest::Test
24
24
  def teardown
25
25
  Timecop.return
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 24.5.0
4
+ version: 24.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Stewart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-13 00:00:00.000000000 Z
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek