gds-api-adapters 7.6.0 → 7.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gds_api/support.rb +8 -0
- data/lib/gds_api/test_helpers/support.rb +12 -0
- data/lib/gds_api/version.rb +1 -1
- data/test/support_api_test.rb +34 -0
- metadata +4 -4
data/lib/gds_api/support.rb
CHANGED
@@ -9,6 +9,14 @@ class GdsApi::Support < GdsApi::Base
|
|
9
9
|
post_json!("#{base_url}/anonymous_feedback/problem_reports", { :problem_report => request_details }, options[:headers] || {})
|
10
10
|
end
|
11
11
|
|
12
|
+
def create_named_contact(request_details, options = {})
|
13
|
+
post_json!("#{base_url}/named_contacts", { :named_contact => request_details }, options[:headers] || {})
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_anonymous_long_form_contact(request_details, options = {})
|
17
|
+
post_json!("#{base_url}/anonymous_feedback/long_form_contacts", { :long_form_contact => request_details }, options[:headers] || {})
|
18
|
+
end
|
19
|
+
|
12
20
|
private
|
13
21
|
def base_url
|
14
22
|
endpoint
|
@@ -15,6 +15,18 @@ module GdsApi
|
|
15
15
|
post_stub.to_return(:status => 201)
|
16
16
|
end
|
17
17
|
|
18
|
+
def stub_support_named_contact_creation(request_details = nil)
|
19
|
+
post_stub = stub_http_request(:post, "#{SUPPORT_ENDPOINT}/named_contacts")
|
20
|
+
post_stub.with(:body => { named_contact: request_details }) unless request_details.nil?
|
21
|
+
post_stub.to_return(:status => 201)
|
22
|
+
end
|
23
|
+
|
24
|
+
def stub_support_long_form_anonymous_contact_creation(request_details = nil)
|
25
|
+
post_stub = stub_http_request(:post, "#{SUPPORT_ENDPOINT}/anonymous_feedback/long_form_contacts")
|
26
|
+
post_stub.with(:body => { long_form_contact: request_details }) unless request_details.nil?
|
27
|
+
post_stub.to_return(:status => 201)
|
28
|
+
end
|
29
|
+
|
18
30
|
def support_isnt_available
|
19
31
|
stub_request(:post, /#{SUPPORT_ENDPOINT}\/.*/).to_return(:status => 503)
|
20
32
|
end
|
data/lib/gds_api/version.rb
CHANGED
data/test/support_api_test.rb
CHANGED
@@ -50,6 +50,18 @@ describe GdsApi::Support do
|
|
50
50
|
assert_requested(stub_post)
|
51
51
|
end
|
52
52
|
|
53
|
+
it "can submit long-form anonymous feedback" do
|
54
|
+
request_details = {certain: "details"}
|
55
|
+
|
56
|
+
stub_post = stub_request(:post, "#{@base_api_url}/anonymous_feedback/long_form_contacts").
|
57
|
+
with(:body => {"long_form_contact" => request_details}.to_json).
|
58
|
+
to_return(:status => 201)
|
59
|
+
|
60
|
+
@api.create_anonymous_long_form_contact(request_details)
|
61
|
+
|
62
|
+
assert_requested(stub_post)
|
63
|
+
end
|
64
|
+
|
53
65
|
it "can add a custom header onto the problem_report request to the support app" do
|
54
66
|
stub_request(:post, "#{@base_api_url}/anonymous_feedback/problem_reports")
|
55
67
|
|
@@ -60,6 +72,28 @@ describe GdsApi::Support do
|
|
60
72
|
end
|
61
73
|
end
|
62
74
|
|
75
|
+
it "can create a named contact" do
|
76
|
+
request_details = {certain: "details"}
|
77
|
+
|
78
|
+
stub_post = stub_request(:post, "#{@base_api_url}/named_contacts").
|
79
|
+
with(:body => {"named_contact" => request_details}.to_json).
|
80
|
+
to_return(:status => 201)
|
81
|
+
|
82
|
+
@api.create_named_contact(request_details)
|
83
|
+
|
84
|
+
assert_requested(stub_post)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "can add a custom header onto the named_contact request to the support app" do
|
88
|
+
stub_request(:post, "#{@base_api_url}/named_contacts")
|
89
|
+
|
90
|
+
@api.create_named_contact({}, headers: { "X-Varnish" => "12345"})
|
91
|
+
|
92
|
+
assert_requested(:post, %r{/named_contacts}) do |request|
|
93
|
+
request.headers["X-Varnish"] == "12345"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
63
97
|
it "throws an exception when the support app isn't available" do
|
64
98
|
support_isnt_available
|
65
99
|
|
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.
|
4
|
+
version: 7.7.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-
|
12
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: plek
|
@@ -332,7 +332,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
332
332
|
version: '0'
|
333
333
|
segments:
|
334
334
|
- 0
|
335
|
-
hash: -
|
335
|
+
hash: -310968660017522617
|
336
336
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
337
337
|
none: false
|
338
338
|
requirements:
|
@@ -341,7 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
341
341
|
version: '0'
|
342
342
|
segments:
|
343
343
|
- 0
|
344
|
-
hash: -
|
344
|
+
hash: -310968660017522617
|
345
345
|
requirements: []
|
346
346
|
rubyforge_project:
|
347
347
|
rubygems_version: 1.8.23
|