gds-api-adapters 7.14.0 → 7.15.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.
- data/lib/gds_api/support.rb +4 -0
- data/lib/gds_api/test_helpers/support.rb +6 -0
- data/lib/gds_api/version.rb +1 -1
- data/test/support_api_test.rb +30 -0
- metadata +4 -4
data/lib/gds_api/support.rb
CHANGED
@@ -17,6 +17,10 @@ class GdsApi::Support < GdsApi::Base
|
|
17
17
|
post_json!("#{base_url}/anonymous_feedback/long_form_contacts", { :long_form_contact => request_details }, options[:headers] || {})
|
18
18
|
end
|
19
19
|
|
20
|
+
def create_transactions(request_details, options = {})
|
21
|
+
post_json!("#{base_url}/anonymous_feedback/transactions", { :transactions => request_details }, options[:headers] || {})
|
22
|
+
end
|
23
|
+
|
20
24
|
private
|
21
25
|
def base_url
|
22
26
|
endpoint
|
@@ -27,6 +27,12 @@ module GdsApi
|
|
27
27
|
post_stub.to_return(:status => 201)
|
28
28
|
end
|
29
29
|
|
30
|
+
def stub_support_transactions_creation(request_details = nil)
|
31
|
+
post_stub = stub_http_request(:post, "#{SUPPORT_ENDPOINT}/anonymous_feedback/transactions")
|
32
|
+
post_stub.with(:body => {"transactions" => request_details}) unless request_details.nil?
|
33
|
+
post_stub.to_return(:status => 201)
|
34
|
+
end
|
35
|
+
|
30
36
|
def support_isnt_available
|
31
37
|
stub_request(:post, /#{SUPPORT_ENDPOINT}\/.*/).to_return(:status => 503)
|
32
38
|
end
|
data/lib/gds_api/version.rb
CHANGED
data/test/support_api_test.rb
CHANGED
@@ -99,4 +99,34 @@ describe GdsApi::Support do
|
|
99
99
|
|
100
100
|
assert_raises(GdsApi::HTTPErrorResponse) { @api.create_problem_report({}) }
|
101
101
|
end
|
102
|
+
|
103
|
+
it "can pass transaction feedback" do
|
104
|
+
request_details = {"transaction-completed-values"=>"1", "details"=>"abc"}
|
105
|
+
|
106
|
+
stub_post = stub_request(:post, "#{@base_api_url}/anonymous_feedback/transactions").
|
107
|
+
with(:body => {"transactions" => request_details}.to_json).
|
108
|
+
to_return(:status => 201)
|
109
|
+
|
110
|
+
@api.create_transactions(request_details)
|
111
|
+
|
112
|
+
assert_requested(stub_post)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "can add a custom header onto the transaction feedback to the support app" do
|
116
|
+
stub_request(:post, "#{@base_api_url}/anonymous_feedback/transactions")
|
117
|
+
|
118
|
+
@api.create_transactions({}, headers: { "X-Varnish" => "12345"})
|
119
|
+
|
120
|
+
assert_requested(:post, %r{/transactions}) do |request|
|
121
|
+
request.headers["X-Varnish"] == "12345"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
it "throws an exception when the support app isn't available" do
|
126
|
+
support_isnt_available
|
127
|
+
|
128
|
+
assert_raises(GdsApi::HTTPErrorResponse) { @api.create_transactions({}) }
|
129
|
+
end
|
130
|
+
|
131
|
+
|
102
132
|
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.
|
4
|
+
version: 7.15.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-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: plek
|
@@ -340,7 +340,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
340
340
|
version: '0'
|
341
341
|
segments:
|
342
342
|
- 0
|
343
|
-
hash:
|
343
|
+
hash: 988402629754510037
|
344
344
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
345
345
|
none: false
|
346
346
|
requirements:
|
@@ -349,7 +349,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
349
349
|
version: '0'
|
350
350
|
segments:
|
351
351
|
- 0
|
352
|
-
hash:
|
352
|
+
hash: 988402629754510037
|
353
353
|
requirements: []
|
354
354
|
rubyforge_project:
|
355
355
|
rubygems_version: 1.8.23
|