gds-api-adapters 7.8.0 → 7.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,7 @@ require 'gds_api/licence_application'
6
6
  require 'gds_api/asset_manager'
7
7
  require 'gds_api/worldwide'
8
8
  require 'gds_api/fact_cave'
9
+ require 'gds_api/need_api'
9
10
 
10
11
  module GdsApi
11
12
  module Helpers
@@ -33,6 +34,10 @@ module GdsApi
33
34
  @licence_application_api ||= GdsApi::LicenceApplication.new(Plek.current.find("licensify"), options)
34
35
  end
35
36
 
37
+ def need_api(options = {})
38
+ @need_api ||= GdsApi::NeedApi.new(Plek.current.find("needapi"), options)
39
+ end
40
+
36
41
  def panopticon_api(options = {})
37
42
  @panopticon_api ||= GdsApi::Panopticon.new(Plek.current.find("panopticon"), panopticon_api_credentials.merge(options))
38
43
  end
@@ -5,4 +5,8 @@ class GdsApi::NeedApi < GdsApi::Base
5
5
  def create_need(need)
6
6
  post_json!("#{endpoint}/needs", need)
7
7
  end
8
+
9
+ def organisations
10
+ get_json("#{endpoint}/organisations")
11
+ end
8
12
  end
@@ -0,0 +1,21 @@
1
+ require 'gds_api/test_helpers/json_client_helper'
2
+
3
+ module GdsApi
4
+ module TestHelpers
5
+ module NeedApi
6
+ # Generally true. If you are initializing the client differently,
7
+ # you could redefine/override the constant or stub directly.
8
+ NEED_API_ENDPOINT = Plek.current.find('needapi')
9
+
10
+ def need_api_has_organisations(organisation_ids)
11
+ url = NEED_API_ENDPOINT + "/organisations"
12
+ orgs = organisation_ids.map do |k,v|
13
+ { "id" => k,
14
+ "name" => v
15
+ }
16
+ end
17
+ stub_request(:get, url).to_return(status: 200, body: orgs.to_json, headers: {})
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '7.8.0'
2
+ VERSION = '7.9.0'
3
3
  end
@@ -1,7 +1,9 @@
1
1
  require 'test_helper'
2
2
  require 'gds_api/need_api'
3
+ require 'gds_api/test_helpers/need_api'
3
4
 
4
5
  describe GdsApi::NeedApi do
6
+ include GdsApi::TestHelpers::NeedApi
5
7
 
6
8
  before do
7
9
  @base_api_url = Plek.current.find("needapi")
@@ -17,4 +19,20 @@ describe GdsApi::NeedApi do
17
19
  assert_requested(request_stub)
18
20
  end
19
21
  end
22
+
23
+ describe "viewing organisations" do
24
+ it "should return a list of organisations" do
25
+ request_stub = need_api_has_organisations(
26
+ "committee-on-climate-change" => "Committee on Climate Change",
27
+ "competition-commission" => "Competition Commission"
28
+ )
29
+
30
+ orgs = @api.organisations()
31
+
32
+ assert_requested(request_stub)
33
+ assert_equal("Committee on Climate Change", orgs[0]["name"])
34
+ assert_equal("Competition Commission", orgs[1]["name"])
35
+ assert_equal(2, orgs.size)
36
+ end
37
+ end
20
38
  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: 7.8.0
4
+ version: 7.9.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: 2013-10-04 00:00:00.000000000 Z
12
+ date: 2013-10-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: plek
@@ -270,6 +270,7 @@ files:
270
270
  - lib/gds_api/version.rb
271
271
  - lib/gds_api/panopticon/registerer.rb
272
272
  - lib/gds_api/test_helpers/support.rb
273
+ - lib/gds_api/test_helpers/need_api.rb
273
274
  - lib/gds_api/test_helpers/content_api/artefact_stub.rb
274
275
  - lib/gds_api/test_helpers/licence_application.rb
275
276
  - lib/gds_api/test_helpers/imminence.rb
@@ -334,7 +335,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
334
335
  version: '0'
335
336
  segments:
336
337
  - 0
337
- hash: 990016573941287017
338
+ hash: 2244458293853807877
338
339
  required_rubygems_version: !ruby/object:Gem::Requirement
339
340
  none: false
340
341
  requirements:
@@ -343,7 +344,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
343
344
  version: '0'
344
345
  segments:
345
346
  - 0
346
- hash: 990016573941287017
347
+ hash: 2244458293853807877
347
348
  requirements: []
348
349
  rubyforge_project:
349
350
  rubygems_version: 1.8.23