gds-api-adapters 11.4.0 → 11.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ require_relative 'base'
2
+
3
+ class GdsApi::SupportApi < GdsApi::Base
4
+ def create_service_feedback(request_details)
5
+ post_json!("#{endpoint}/anonymous-feedback/service-feedback", { :service_feedback => request_details })
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ module GdsApi
2
+ module TestHelpers
3
+ module SupportApi
4
+ SUPPORT_API_ENDPOINT = Plek.current.find('support-api')
5
+
6
+ def stub_support_api_service_feedback_creation(feedback_details = nil)
7
+ post_stub = stub_http_request(:post, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/service-feedback")
8
+ post_stub.with(:body => { service_feedback: feedback_details }) unless feedback_details.nil?
9
+ post_stub.to_return(:status => 201)
10
+ end
11
+
12
+ def support_api_isnt_available
13
+ stub_request(:post, /#{SUPPORT_API_ENDPOINT}\/.*/).to_return(:status => 503)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '11.4.0'
2
+ VERSION = '11.5.0'
3
3
  end
@@ -1,79 +1,19 @@
1
1
  require 'test_helper'
2
- require 'gds_api/support'
3
- require 'gds_api/test_helpers/support'
2
+ require 'gds_api/support_api'
3
+ require 'gds_api/test_helpers/support_api'
4
4
 
5
- describe GdsApi::Support do
6
- include GdsApi::TestHelpers::Support
5
+ describe GdsApi::SupportApi do
6
+ include GdsApi::TestHelpers::SupportApi
7
7
 
8
8
  before do
9
- @base_api_url = Plek.current.find("support")
10
- @api = GdsApi::Support.new(@base_api_url)
11
- end
12
-
13
- it "can create an FOI request" do
14
- request_details = {"foi_request"=>{"requester"=>{"name"=>"A", "email"=>"a@b.com"}, "details"=>"abc"}}
15
-
16
- stub_post = stub_request(:post, "#{@base_api_url}/foi_requests").
17
- with(:body => {"foi_request" => request_details}.to_json).
18
- to_return(:status => 201)
19
-
20
- @api.create_foi_request(request_details)
21
-
22
- assert_requested(stub_post)
23
- end
24
-
25
- it "throws an exception when the support app isn't available" do
26
- support_isnt_available
27
-
28
- assert_raises(GdsApi::HTTPErrorResponse) { @api.create_foi_request({}) }
29
- end
30
-
31
- it "can report a problem" do
32
- request_details = {certain: "details"}
33
-
34
- stub_post = stub_request(:post, "#{@base_api_url}/anonymous_feedback/problem_reports").
35
- with(:body => {"problem_report" => request_details}.to_json).
36
- to_return(:status => 201)
37
-
38
- @api.create_problem_report(request_details)
39
-
40
- assert_requested(stub_post)
41
- end
42
-
43
- it "can submit long-form anonymous feedback" do
44
- request_details = {certain: "details"}
45
-
46
- stub_post = stub_request(:post, "#{@base_api_url}/anonymous_feedback/long_form_contacts").
47
- with(:body => {"long_form_contact" => request_details}.to_json).
48
- to_return(:status => 201)
49
-
50
- @api.create_anonymous_long_form_contact(request_details)
51
-
52
- assert_requested(stub_post)
53
- end
54
-
55
- it "can create a named contact" do
56
- request_details = {certain: "details"}
57
-
58
- stub_post = stub_request(:post, "#{@base_api_url}/named_contacts").
59
- with(:body => {"named_contact" => request_details}.to_json).
60
- to_return(:status => 201)
61
-
62
- @api.create_named_contact(request_details)
63
-
64
- assert_requested(stub_post)
65
- end
66
-
67
- it "throws an exception when the support app isn't available" do
68
- support_isnt_available
69
-
70
- assert_raises(GdsApi::HTTPErrorResponse) { @api.create_problem_report({}) }
9
+ @base_api_url = Plek.current.find("support-api")
10
+ @api = GdsApi::SupportApi.new(@base_api_url)
71
11
  end
72
12
 
73
13
  it "can pass service feedback" do
74
14
  request_details = {"transaction-completed-values"=>"1", "details"=>"abc"}
75
15
 
76
- stub_post = stub_request(:post, "#{@base_api_url}/anonymous_feedback/service_feedback").
16
+ stub_post = stub_request(:post, "#{@base_api_url}/anonymous-feedback/service-feedback").
77
17
  with(:body => {"service_feedback" => request_details}.to_json).
78
18
  to_return(:status => 201)
79
19
 
@@ -83,14 +23,8 @@ describe GdsApi::Support do
83
23
  end
84
24
 
85
25
  it "throws an exception when the support app isn't available" do
86
- support_isnt_available
26
+ support_api_isnt_available
87
27
 
88
28
  assert_raises(GdsApi::HTTPErrorResponse) { @api.create_service_feedback({}) }
89
29
  end
90
-
91
- it "gets the correct feedback URL" do
92
- assert_equal("#{@base_api_url}/anonymous_feedback?path=foo",
93
- @api.feedback_url('foo'))
94
-
95
- end
96
30
  end
@@ -0,0 +1,96 @@
1
+ require 'test_helper'
2
+ require 'gds_api/support'
3
+ require 'gds_api/test_helpers/support'
4
+
5
+ describe GdsApi::Support do
6
+ include GdsApi::TestHelpers::Support
7
+
8
+ before do
9
+ @base_api_url = Plek.current.find("support")
10
+ @api = GdsApi::Support.new(@base_api_url)
11
+ end
12
+
13
+ it "can create an FOI request" do
14
+ request_details = {"foi_request"=>{"requester"=>{"name"=>"A", "email"=>"a@b.com"}, "details"=>"abc"}}
15
+
16
+ stub_post = stub_request(:post, "#{@base_api_url}/foi_requests").
17
+ with(:body => {"foi_request" => request_details}.to_json).
18
+ to_return(:status => 201)
19
+
20
+ @api.create_foi_request(request_details)
21
+
22
+ assert_requested(stub_post)
23
+ end
24
+
25
+ it "throws an exception when the support app isn't available" do
26
+ support_isnt_available
27
+
28
+ assert_raises(GdsApi::HTTPErrorResponse) { @api.create_foi_request({}) }
29
+ end
30
+
31
+ it "can report a problem" do
32
+ request_details = {certain: "details"}
33
+
34
+ stub_post = stub_request(:post, "#{@base_api_url}/anonymous_feedback/problem_reports").
35
+ with(:body => {"problem_report" => request_details}.to_json).
36
+ to_return(:status => 201)
37
+
38
+ @api.create_problem_report(request_details)
39
+
40
+ assert_requested(stub_post)
41
+ end
42
+
43
+ it "can submit long-form anonymous feedback" do
44
+ request_details = {certain: "details"}
45
+
46
+ stub_post = stub_request(:post, "#{@base_api_url}/anonymous_feedback/long_form_contacts").
47
+ with(:body => {"long_form_contact" => request_details}.to_json).
48
+ to_return(:status => 201)
49
+
50
+ @api.create_anonymous_long_form_contact(request_details)
51
+
52
+ assert_requested(stub_post)
53
+ end
54
+
55
+ it "can create a named contact" do
56
+ request_details = {certain: "details"}
57
+
58
+ stub_post = stub_request(:post, "#{@base_api_url}/named_contacts").
59
+ with(:body => {"named_contact" => request_details}.to_json).
60
+ to_return(:status => 201)
61
+
62
+ @api.create_named_contact(request_details)
63
+
64
+ assert_requested(stub_post)
65
+ end
66
+
67
+ it "throws an exception when the support app isn't available" do
68
+ support_isnt_available
69
+
70
+ assert_raises(GdsApi::HTTPErrorResponse) { @api.create_problem_report({}) }
71
+ end
72
+
73
+ it "can pass service feedback" do
74
+ request_details = {"transaction-completed-values"=>"1", "details"=>"abc"}
75
+
76
+ stub_post = stub_request(:post, "#{@base_api_url}/anonymous_feedback/service_feedback").
77
+ with(:body => {"service_feedback" => request_details}.to_json).
78
+ to_return(:status => 201)
79
+
80
+ @api.create_service_feedback(request_details)
81
+
82
+ assert_requested(stub_post)
83
+ end
84
+
85
+ it "throws an exception when the support app isn't available" do
86
+ support_isnt_available
87
+
88
+ assert_raises(GdsApi::HTTPErrorResponse) { @api.create_service_feedback({}) }
89
+ end
90
+
91
+ it "gets the correct feedback URL" do
92
+ assert_equal("#{@base_api_url}/anonymous_feedback?path=foo",
93
+ @api.feedback_url('foo'))
94
+
95
+ end
96
+ 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: 11.4.0
4
+ version: 11.5.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: 2014-07-02 00:00:00.000000000 Z
12
+ date: 2014-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: plek
@@ -303,6 +303,7 @@ files:
303
303
  - lib/gds_api/test_helpers/mapit.rb
304
304
  - lib/gds_api/test_helpers/panopticon.rb
305
305
  - lib/gds_api/test_helpers/json_client_helper.rb
306
+ - lib/gds_api/test_helpers/support_api.rb
306
307
  - lib/gds_api/test_helpers/content_store.rb
307
308
  - lib/gds_api/test_helpers/asset_manager.rb
308
309
  - lib/gds_api/test_helpers/gov_uk_delivery.rb
@@ -323,6 +324,7 @@ files:
323
324
  - lib/gds_api/helpers.rb
324
325
  - lib/gds_api/middleware/govuk_request_id_sniffer.rb
325
326
  - lib/gds_api/panopticon.rb
327
+ - lib/gds_api/support_api.rb
326
328
  - lib/gds_api/content_store.rb
327
329
  - lib/gds_api/asset_manager.rb
328
330
  - lib/gds_api/gov_uk_delivery.rb
@@ -342,6 +344,7 @@ files:
342
344
  - test/finder_schema_test.rb
343
345
  - test/need_api_test.rb
344
346
  - test/publisher_api_test.rb
347
+ - test/support_test.rb
345
348
  - test/fact_cave_test.rb
346
349
  - test/finder_api_test.rb
347
350
  - test/licence_application_api_test.rb
@@ -382,7 +385,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
382
385
  version: '0'
383
386
  segments:
384
387
  - 0
385
- hash: -3744965370006170691
388
+ hash: -724725384917283612
386
389
  required_rubygems_version: !ruby/object:Gem::Requirement
387
390
  none: false
388
391
  requirements:
@@ -391,7 +394,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
391
394
  version: '0'
392
395
  segments:
393
396
  - 0
394
- hash: -3744965370006170691
397
+ hash: -724725384917283612
395
398
  requirements: []
396
399
  rubyforge_project:
397
400
  rubygems_version: 1.8.23
@@ -405,6 +408,7 @@ test_files:
405
408
  - test/finder_schema_test.rb
406
409
  - test/need_api_test.rb
407
410
  - test/publisher_api_test.rb
411
+ - test/support_test.rb
408
412
  - test/fact_cave_test.rb
409
413
  - test/finder_api_test.rb
410
414
  - test/licence_application_api_test.rb