gds-api-adapters 7.12.0 → 7.13.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,8 +2,10 @@ require_relative 'base'
2
2
 
3
3
  class GdsApi::NeedApi < GdsApi::Base
4
4
 
5
- def needs
6
- get_list!("#{endpoint}/needs")
5
+ def needs(options = {})
6
+ query = query_string(options)
7
+
8
+ get_list!("#{endpoint}/needs#{query}")
7
9
  end
8
10
 
9
11
  def create_need(need)
@@ -22,6 +22,15 @@ module GdsApi
22
22
  stub_request(:get, url).to_return(status: 200, body: body.to_json, headers: {})
23
23
  end
24
24
 
25
+ def need_api_has_needs_for_organisation(organisation, needs)
26
+ url = NEED_API_ENDPOINT + "/needs?organisation_id=#{organisation}"
27
+
28
+ body = response_base.merge(
29
+ "results" => needs
30
+ )
31
+ stub_request(:get, url).to_return(status: 200, body: body.to_json, headers: {})
32
+ end
33
+
25
34
  def need_api_has_needs(needs)
26
35
  url = NEED_API_ENDPOINT + "/needs"
27
36
 
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '7.12.0'
2
+ VERSION = '7.13.0'
3
3
  end
@@ -79,6 +79,56 @@ describe GdsApi::NeedApi do
79
79
  end
80
80
  end
81
81
 
82
+ describe "filtering needs by organisation" do
83
+ it "should return a subset of needs" do
84
+ req = need_api_has_needs_for_organisation("ministry-of-justice", [
85
+ {
86
+ "role" => "parent",
87
+ "goal" => "apply for a primary school place",
88
+ "benefit" => "my child can start school",
89
+ "organisation_ids" => ["ministry-of-justice"],
90
+ "organisations" => [
91
+ {
92
+ "id" => "ministry-of-justice",
93
+ "name" => "Ministry of Justice",
94
+ }
95
+ ],
96
+ "justifications" => [
97
+ "it's something only government does",
98
+ "the government is legally obliged to provide it"
99
+ ],
100
+ "impact" => "Has serious consequences for the day-to-day lives of your users",
101
+ "met_when" => [
102
+ "The user applies for a school place"
103
+ ]
104
+ },
105
+ {
106
+ "role" => "user",
107
+ "goal" => "find out about becoming a British citizen",
108
+ "benefit" => "i can take the correct steps to apply for citizenship",
109
+ "organisation_ids" => ["ministry-of-justice"],
110
+ "organisations" => [
111
+ {
112
+ "id" => "ministry-of-justice",
113
+ "name" => "Ministry of Justice",
114
+ }
115
+ ],
116
+ "justifications" => [
117
+ "it's something only government does",
118
+ "the government is legally obliged to provide it"
119
+ ],
120
+ "impact" => "Has serious consequences for the day-to-day lives of your users",
121
+ "met_when" => [
122
+ "The user finds information about the citizenship test and the next steps"
123
+ ]
124
+ }
125
+ ])
126
+
127
+ @api.needs(organisation_id: "ministry-of-justice")
128
+ assert_requested(req)
129
+ end
130
+ end
131
+
82
132
  describe "viewing organisations" do
83
133
  it "should return a list of organisations" do
84
134
  request_stub = need_api_has_organisations(
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.12.0
4
+ version: 7.13.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-16 00:00:00.000000000 Z
12
+ date: 2013-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: plek
@@ -338,7 +338,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
338
338
  version: '0'
339
339
  segments:
340
340
  - 0
341
- hash: -2562720960350177720
341
+ hash: -3882474794805816869
342
342
  required_rubygems_version: !ruby/object:Gem::Requirement
343
343
  none: false
344
344
  requirements:
@@ -347,7 +347,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
347
347
  version: '0'
348
348
  segments:
349
349
  - 0
350
- hash: -2562720960350177720
350
+ hash: -3882474794805816869
351
351
  requirements: []
352
352
  rubyforge_project:
353
353
  rubygems_version: 1.8.23