active_utils 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -48,6 +48,15 @@ module ActiveMerchant
|
|
48
48
|
when :post
|
49
49
|
debug body
|
50
50
|
http.post(endpoint.request_uri, body, RUBY_184_POST_HEADERS.merge(headers))
|
51
|
+
when :put
|
52
|
+
debug body
|
53
|
+
http.put(endpoint.request_uri, body, headers)
|
54
|
+
when :delete
|
55
|
+
# It's kind of ambiguous whether the RFC allows bodies
|
56
|
+
# for DELETE requests. But Net::HTTP's delete method
|
57
|
+
# very unambiguously does not.
|
58
|
+
raise ArgumentError, "DELETE requests do not support a request body" if body
|
59
|
+
http.delete(endpoint.request_uri, headers)
|
51
60
|
else
|
52
61
|
raise ArgumentError, "Unsupported request method #{method.to_s.upcase}"
|
53
62
|
end
|
@@ -31,7 +31,7 @@ module ActiveMerchant #:nodoc:
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def raw_ssl_request(method, endpoint, data, headers = {})
|
34
|
-
connection =
|
34
|
+
connection = new_connection(endpoint)
|
35
35
|
connection.open_timeout = open_timeout
|
36
36
|
connection.read_timeout = read_timeout
|
37
37
|
connection.retry_safe = retry_safe
|
@@ -50,6 +50,10 @@ module ActiveMerchant #:nodoc:
|
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
+
def new_connection(endpoint)
|
54
|
+
Connection.new(endpoint)
|
55
|
+
end
|
56
|
+
|
53
57
|
def handle_response(response)
|
54
58
|
case response.code.to_i
|
55
59
|
when 200...300
|
data/lib/active_utils/version.rb
CHANGED
@@ -37,6 +37,18 @@ class ConnectionTest < Test::Unit::TestCase
|
|
37
37
|
assert_equal 'success', response.body
|
38
38
|
end
|
39
39
|
|
40
|
+
def test_successful_put_request
|
41
|
+
Net::HTTP.any_instance.expects(:put).with('/tx.php', 'data', {}).returns(@ok)
|
42
|
+
response = @connection.request(:put, 'data', {})
|
43
|
+
assert_equal 'success', response.body
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_successful_delete_request
|
47
|
+
Net::HTTP.any_instance.expects(:delete).with('/tx.php', {}).returns(@ok)
|
48
|
+
response = @connection.request(:delete, nil, {})
|
49
|
+
assert_equal 'success', response.body
|
50
|
+
end
|
51
|
+
|
40
52
|
def test_get_raises_argument_error_if_passed_data
|
41
53
|
assert_raise(ArgumentError) do
|
42
54
|
@connection.request(:get, 'data', {})
|
@@ -45,7 +57,7 @@ class ConnectionTest < Test::Unit::TestCase
|
|
45
57
|
|
46
58
|
def test_request_raises_when_request_method_not_supported
|
47
59
|
assert_raise(ArgumentError) do
|
48
|
-
@connection.request(:
|
60
|
+
@connection.request(:head, nil, {})
|
49
61
|
end
|
50
62
|
end
|
51
63
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Shopify
|
@@ -15,13 +15,13 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-01-16 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: activesupport
|
23
23
|
prerelease: false
|
24
|
-
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
@@ -33,11 +33,11 @@ dependencies:
|
|
33
33
|
- 11
|
34
34
|
version: 2.3.11
|
35
35
|
type: :runtime
|
36
|
-
|
36
|
+
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: i18n
|
39
39
|
prerelease: false
|
40
|
-
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
@@ -47,11 +47,11 @@ dependencies:
|
|
47
47
|
- 0
|
48
48
|
version: "0"
|
49
49
|
type: :runtime
|
50
|
-
|
50
|
+
version_requirements: *id002
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
52
|
name: rake
|
53
53
|
prerelease: false
|
54
|
-
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
55
|
none: false
|
56
56
|
requirements:
|
57
57
|
- - ">="
|
@@ -61,11 +61,11 @@ dependencies:
|
|
61
61
|
- 0
|
62
62
|
version: "0"
|
63
63
|
type: :development
|
64
|
-
|
64
|
+
version_requirements: *id003
|
65
65
|
- !ruby/object:Gem::Dependency
|
66
66
|
name: mocha
|
67
67
|
prerelease: false
|
68
|
-
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
69
|
none: false
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
@@ -75,7 +75,7 @@ dependencies:
|
|
75
75
|
- 0
|
76
76
|
version: "0"
|
77
77
|
type: :development
|
78
|
-
|
78
|
+
version_requirements: *id004
|
79
79
|
description:
|
80
80
|
email:
|
81
81
|
- developers@jadedpixel.com
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
requirements: []
|
141
141
|
|
142
142
|
rubyforge_project: active_utils
|
143
|
-
rubygems_version: 1.
|
143
|
+
rubygems_version: 1.5.3
|
144
144
|
signing_key:
|
145
145
|
specification_version: 3
|
146
146
|
summary: Common utils used by active_merchant, active_fulfillment, and active_shipping
|