ruby-ecomm-client 1.0.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/.gitignore +22 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +12 -0
- data/fixtures/vcr_cassettes/account_info/default.yml +42 -0
- data/fixtures/vcr_cassettes/account_info/unknown/resource_id.yml +42 -0
- data/fixtures/vcr_cassettes/account_info/unknown/resource_type.yml +42 -0
- data/fixtures/vcr_cassettes/account_info/unknown/source_tree_id.yml +42 -0
- data/fixtures/vcr_cassettes/downgrade/default.yml +42 -0
- data/fixtures/vcr_cassettes/downgrade/noop.yml +42 -0
- data/fixtures/vcr_cassettes/downgrade/unknown/resource_id.yml +42 -0
- data/fixtures/vcr_cassettes/downgrade/unknown/resource_type.yml +42 -0
- data/fixtures/vcr_cassettes/downgrade/unknown/target_tree_id.yml +42 -0
- data/fixtures/vcr_cassettes/express_checkout/configured.yml +40 -0
- data/fixtures/vcr_cassettes/express_checkout/unknown.yml +40 -0
- data/fixtures/vcr_cassettes/transitions/default/unknown/source_tree_id.yml +42 -0
- data/fixtures/vcr_cassettes/transitions/many.yml +42 -0
- data/fixtures/vcr_cassettes/transitions/one.yml +42 -0
- data/fixtures/vcr_cassettes/transitions/unknown/source_tree_id.yml +42 -0
- data/fixtures/vcr_cassettes/upgrade/default.yml +42 -0
- data/fixtures/vcr_cassettes/upgrade/noop.yml +42 -0
- data/fixtures/vcr_cassettes/upgrade/unknown/resource_id.yml +42 -0
- data/fixtures/vcr_cassettes/upgrade/unknown/resource_type.yml +42 -0
- data/fixtures/vcr_cassettes/upgrade/unknown/target_tree_id.yml +42 -0
- data/lib/ruby-ecomm-client.rb +10 -0
- data/lib/ruby-ecomm-client/client.rb +148 -0
- data/lib/ruby-ecomm-client/converter.rb +45 -0
- data/lib/ruby-ecomm-client/error.rb +12 -0
- data/lib/ruby-ecomm-client/version.rb +3 -0
- data/lib/ruby-ecomm-client/wsdl/manager.wsdl +296 -0
- data/lib/ruby-ecomm-client/wsdl/profile.wsdl +66 -0
- data/lib/ruby-ecomm-client/wsdl/purchase.wsdl +74 -0
- data/ruby-ecomm-client.gemspec +30 -0
- data/script/cibuild +10 -0
- data/spec/ruby-ecomm-client/client_spec.rb +297 -0
- data/spec/ruby-ecomm-client/converter_spec.rb +96 -0
- data/spec/ruby-ecomm-client/error_spec.rb +39 -0
- data/spec/spec_helper.rb +21 -0
- metadata +237 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
|
3
|
+
<wsdl:types>
|
4
|
+
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
|
5
|
+
<s:element name="ShopperHasInstantPurchasePayment">
|
6
|
+
<s:complexType>
|
7
|
+
<s:sequence>
|
8
|
+
<s:element minOccurs="0" maxOccurs="1" name="sShopperID" type="s:string" />
|
9
|
+
</s:sequence>
|
10
|
+
</s:complexType>
|
11
|
+
</s:element>
|
12
|
+
<s:element name="ShopperHasInstantPurchasePaymentResponse">
|
13
|
+
<s:complexType>
|
14
|
+
<s:sequence>
|
15
|
+
<s:element minOccurs="0" maxOccurs="1" name="ShopperHasInstantPurchasePaymentResult" type="s:string" />
|
16
|
+
<s:element minOccurs="1" maxOccurs="1" name="bHasInstantPurchasePayment" type="s:boolean" />
|
17
|
+
</s:sequence>
|
18
|
+
</s:complexType>
|
19
|
+
</s:element>
|
20
|
+
</s:schema>
|
21
|
+
</wsdl:types>
|
22
|
+
<wsdl:message name="ShopperHasInstantPurchasePaymentSoapIn">
|
23
|
+
<wsdl:part name="parameters" element="tns:ShopperHasInstantPurchasePayment" />
|
24
|
+
</wsdl:message>
|
25
|
+
<wsdl:message name="ShopperHasInstantPurchasePaymentSoapOut">
|
26
|
+
<wsdl:part name="parameters" element="tns:ShopperHasInstantPurchasePaymentResponse" />
|
27
|
+
</wsdl:message>
|
28
|
+
<wsdl:portType name="ServiceSoap">
|
29
|
+
<wsdl:operation name="ShopperHasInstantPurchasePayment">
|
30
|
+
<wsdl:input message="tns:ShopperHasInstantPurchasePaymentSoapIn" />
|
31
|
+
<wsdl:output message="tns:ShopperHasInstantPurchasePaymentSoapOut" />
|
32
|
+
</wsdl:operation>
|
33
|
+
</wsdl:portType>
|
34
|
+
<wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
|
35
|
+
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
|
36
|
+
<wsdl:operation name="ShopperHasInstantPurchasePayment">
|
37
|
+
<soap:operation soapAction="http://tempuri.org/ShopperHasInstantPurchasePayment" style="document" />
|
38
|
+
<wsdl:input>
|
39
|
+
<soap:body use="literal" />
|
40
|
+
</wsdl:input>
|
41
|
+
<wsdl:output>
|
42
|
+
<soap:body use="literal" />
|
43
|
+
</wsdl:output>
|
44
|
+
</wsdl:operation>
|
45
|
+
</wsdl:binding>
|
46
|
+
<wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
|
47
|
+
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
|
48
|
+
<wsdl:operation name="ShopperHasInstantPurchasePayment">
|
49
|
+
<soap12:operation soapAction="http://tempuri.org/ShopperHasInstantPurchasePayment" style="document" />
|
50
|
+
<wsdl:input>
|
51
|
+
<soap12:body use="literal" />
|
52
|
+
</wsdl:input>
|
53
|
+
<wsdl:output>
|
54
|
+
<soap12:body use="literal" />
|
55
|
+
</wsdl:output>
|
56
|
+
</wsdl:operation>
|
57
|
+
</wsdl:binding>
|
58
|
+
<wsdl:service name="Service">
|
59
|
+
<wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
|
60
|
+
<soap:address location="http://gdcomm.dev.glbt1.gdg/WSgdInstantPurchasePublic/Service.asmx" />
|
61
|
+
</wsdl:port>
|
62
|
+
<wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
|
63
|
+
<soap12:address location="http://gdcomm.dev.glbt1.gdg/WSgdInstantPurchasePublic/Service.asmx" />
|
64
|
+
</wsdl:port>
|
65
|
+
</wsdl:service>
|
66
|
+
</wsdl:definitions>
|
@@ -0,0 +1,74 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="#Bonsai" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="#Bonsai" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
|
3
|
+
<wsdl:types>
|
4
|
+
<s:schema elementFormDefault="qualified" targetNamespace="#Bonsai">
|
5
|
+
<s:element name="PurchaseChangeAccountRequest">
|
6
|
+
<s:complexType>
|
7
|
+
<s:sequence>
|
8
|
+
<s:element minOccurs="0" maxOccurs="1" name="ResourceID" type="s:string" />
|
9
|
+
<s:element minOccurs="0" maxOccurs="1" name="ResourceType" type="s:string" />
|
10
|
+
<s:element minOccurs="0" maxOccurs="1" name="IDType" type="s:string" />
|
11
|
+
<s:element minOccurs="0" maxOccurs="1" name="AccountPurchaseChangeXml" type="s:string" />
|
12
|
+
<s:element minOccurs="1" maxOccurs="1" name="RenewalPFID" type="s:int" />
|
13
|
+
<s:element minOccurs="1" maxOccurs="1" name="RenewalPeriods" type="s:int" />
|
14
|
+
<s:element minOccurs="0" maxOccurs="1" name="ItemRequestXml" type="s:string" />
|
15
|
+
</s:sequence>
|
16
|
+
</s:complexType>
|
17
|
+
</s:element>
|
18
|
+
<s:element name="PurchaseChangeAccountRequestResponse">
|
19
|
+
<s:complexType>
|
20
|
+
<s:sequence>
|
21
|
+
<s:element minOccurs="1" maxOccurs="1" name="PurchaseChangeAccountRequestResult" type="s:int" />
|
22
|
+
<s:element minOccurs="1" maxOccurs="1" name="ResultCode" type="s:int" />
|
23
|
+
<s:element minOccurs="0" maxOccurs="1" name="Error" type="s:string" />
|
24
|
+
<s:element minOccurs="0" maxOccurs="1" name="OrderXml" type="s:string" />
|
25
|
+
</s:sequence>
|
26
|
+
</s:complexType>
|
27
|
+
</s:element>
|
28
|
+
</s:schema>
|
29
|
+
</wsdl:types>
|
30
|
+
<wsdl:message name="PurchaseChangeAccountRequestSoapIn">
|
31
|
+
<wsdl:part name="parameters" element="tns:PurchaseChangeAccountRequest" />
|
32
|
+
</wsdl:message>
|
33
|
+
<wsdl:message name="PurchaseChangeAccountRequestSoapOut">
|
34
|
+
<wsdl:part name="parameters" element="tns:PurchaseChangeAccountRequestResponse" />
|
35
|
+
</wsdl:message>
|
36
|
+
<wsdl:portType name="ServiceSoap">
|
37
|
+
<wsdl:operation name="PurchaseChangeAccountRequest">
|
38
|
+
<wsdl:input message="tns:PurchaseChangeAccountRequestSoapIn" />
|
39
|
+
<wsdl:output message="tns:PurchaseChangeAccountRequestSoapOut" />
|
40
|
+
</wsdl:operation>
|
41
|
+
</wsdl:portType>
|
42
|
+
<wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
|
43
|
+
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
|
44
|
+
<wsdl:operation name="PurchaseChangeAccountRequest">
|
45
|
+
<soap:operation soapAction="#Bonsai/PurchaseChangeAccountRequest" style="document" />
|
46
|
+
<wsdl:input>
|
47
|
+
<soap:body use="literal" />
|
48
|
+
</wsdl:input>
|
49
|
+
<wsdl:output>
|
50
|
+
<soap:body use="literal" />
|
51
|
+
</wsdl:output>
|
52
|
+
</wsdl:operation>
|
53
|
+
</wsdl:binding>
|
54
|
+
<wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
|
55
|
+
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
|
56
|
+
<wsdl:operation name="PurchaseChangeAccountRequest">
|
57
|
+
<soap12:operation soapAction="#Bonsai/PurchaseChangeAccountRequest" style="document" />
|
58
|
+
<wsdl:input>
|
59
|
+
<soap12:body use="literal" />
|
60
|
+
</wsdl:input>
|
61
|
+
<wsdl:output>
|
62
|
+
<soap12:body use="literal" />
|
63
|
+
</wsdl:output>
|
64
|
+
</wsdl:operation>
|
65
|
+
</wsdl:binding>
|
66
|
+
<wsdl:service name="Service">
|
67
|
+
<wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
|
68
|
+
<soap:address location="https://localhost/BonsaiPurchase/Service.asmx" />
|
69
|
+
</wsdl:port>
|
70
|
+
<wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
|
71
|
+
<soap12:address location="https://localhost/BonsaiPurchase/Service.asmx" />
|
72
|
+
</wsdl:port>
|
73
|
+
</wsdl:service>
|
74
|
+
</wsdl:definitions>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruby-ecomm-client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "ruby-ecomm-client"
|
8
|
+
gem.version = RubyEcommClient::VERSION
|
9
|
+
gem.authors = ["Shelby Sanders"]
|
10
|
+
gem.email = ["ssanders@godaddy.com"]
|
11
|
+
gem.description = %q{Easy access to the e-commerce web services via Ruby}
|
12
|
+
gem.summary = %q{Easy access to the e-commerce web services via Ruby}
|
13
|
+
gem.homepage = "https://github.secureserver.net/outright/ruby-ecomm-client"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_development_dependency "rake", "10.1.1"
|
21
|
+
gem.add_development_dependency "ci_reporter"
|
22
|
+
gem.add_development_dependency 'fakeweb'
|
23
|
+
gem.add_development_dependency "gemfury"
|
24
|
+
gem.add_development_dependency "rcov"
|
25
|
+
gem.add_development_dependency "rspec"
|
26
|
+
gem.add_development_dependency 'vcr'
|
27
|
+
|
28
|
+
gem.add_runtime_dependency "nokogiri", "1.5.10"
|
29
|
+
gem.add_runtime_dependency "savon"
|
30
|
+
end
|
data/script/cibuild
ADDED
@@ -0,0 +1,297 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyEcommClient::Client do
|
4
|
+
before do
|
5
|
+
@shopper_id = '255528'
|
6
|
+
@downgrade_tree_id = '1734'
|
7
|
+
@current_tree_id = '1735'
|
8
|
+
@upgrade_tree_id = '1736'
|
9
|
+
@resource_type = 'outright'
|
10
|
+
@resource_id = 'e1dd6ab9-b072-11e3-9aad-005056953ce3'
|
11
|
+
|
12
|
+
@client = RubyEcommClient::Client.new(@shopper_id, @resource_type, @resource_id)
|
13
|
+
end
|
14
|
+
|
15
|
+
context '#initialize' do
|
16
|
+
it 'require shopper_id non-nil' do
|
17
|
+
expect { RubyEcommClient::Client.new(nil, @resource_type, @resource_id) }.to raise_error(ArgumentError)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'require shopper_id non-blank' do
|
21
|
+
expect { RubyEcommClient::Client.new('', @resource_type, @resource_id) }.to raise_error(ArgumentError)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'require resource_type non-nil' do
|
25
|
+
expect { RubyEcommClient::Client.new(@shopper_id, nil, @resource_id) }.to raise_error(ArgumentError)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'require resource_type non-blank' do
|
29
|
+
expect { RubyEcommClient::Client.new(@shopper_id, '', @resource_id) }.to raise_error(ArgumentError)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'require resource_id non-nil' do
|
33
|
+
expect { RubyEcommClient::Client.new(@shopper_id, @resource_type, nil) }.to raise_error(ArgumentError)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'require resource_id non-blank' do
|
37
|
+
expect { RubyEcommClient::Client.new(@shopper_id, @resource_type, '') }.to raise_error(ArgumentError)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'set shopper_id' do
|
41
|
+
@client.shopper_id.should eq(@shopper_id)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'set resource_type' do
|
45
|
+
@client.resource_type.should eq(@resource_type)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'set resource_id' do
|
49
|
+
@client.resource_id.should eq(@resource_id)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context '#environment' do
|
54
|
+
it 'not be nil' do
|
55
|
+
RubyEcommClient::Client.environment.should_not be_nil
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'not be blank' do
|
59
|
+
RubyEcommClient::Client.environment.should_not eq('')
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'honor ENV' do
|
63
|
+
old_env = ENV['RAILS_ENV']
|
64
|
+
ENV['RAILS_ENV'] = 'production'
|
65
|
+
RubyEcommClient::Client.environment.should eq(:production)
|
66
|
+
ENV['RAILS_ENV'] = old_env
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context '#express_checkout?' do
|
71
|
+
it 'return false for unknown' do
|
72
|
+
VCR.use_cassette('express_checkout/unknown') do
|
73
|
+
@client.shopper_id = '101010'
|
74
|
+
@client.express_checkout?.should eq(false)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'return true when configured' do
|
79
|
+
VCR.use_cassette('express_checkout/configured') do
|
80
|
+
@client.express_checkout?.should eq(true)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context '#account_info' do
|
86
|
+
before do
|
87
|
+
VCR.use_cassette('account_info/default') do
|
88
|
+
@account_info = @client.account_info
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'raise RubyEcommError for unknown resource_type' do
|
93
|
+
VCR.use_cassette('account_info/unknown/resource_type') do
|
94
|
+
@client.resource_type = 'flugel'
|
95
|
+
expect { @client.account_info }.to raise_error(RubyEcommError){|e| e.result_code.should eq(-100) }
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'raise RubyEcommError for unknown resource_id' do
|
100
|
+
VCR.use_cassette('account_info/unknown/resource_id') do
|
101
|
+
@client.resource_id = 'unknown'
|
102
|
+
expect { @client.account_info }.to raise_error(RubyEcommError){|e| e.result_code.should eq(-304) }
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'raise RubyEcommError for unknown source_tree_id' do
|
107
|
+
VCR.use_cassette('account_info/unknown/source_tree_id') do
|
108
|
+
expect { @client.account_info(90909) }.to raise_error(RubyEcommError){|e| e.result_code.should eq(-999) }
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'return a Hash' do
|
113
|
+
@account_info.class.should eq(Hash)
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'include product_id' do
|
117
|
+
@account_info[:product_id].class.should eq(Fixnum)
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'include tree_id' do
|
121
|
+
@account_info[:tree_id].class.should eq(Fixnum)
|
122
|
+
@account_info[:tree_id].should eq(@current_tree_id.to_i)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'include is_free' do
|
126
|
+
@account_info[:is_free].class.should eq(FalseClass)
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'include tree Hash' do
|
130
|
+
@account_info[:tree].class.should eq(Hash)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context '#transitions' do
|
135
|
+
it 'raise RubyEcommError for unknown source_tree_id' do
|
136
|
+
VCR.use_cassette('transitions/default/unknown/source_tree_id') do
|
137
|
+
expect { @client.transitions(87563) }.to raise_error(RubyEcommError){|e| e.result_code.should eq(-999) }
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context '#transitions for one' do
|
143
|
+
before do
|
144
|
+
VCR.use_cassette('transitions/one') do
|
145
|
+
@transitions = @client.transitions(@downgrade_tree_id)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'return an Array' do
|
150
|
+
@transitions.class.should eq(Array)
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'return multiple' do
|
154
|
+
@transitions.size.should eq(1)
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'return containing Hashes' do
|
158
|
+
@transitions.first.class.should eq(Hash)
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'return containing Hashes with product_id' do
|
162
|
+
@transitions.first[:product_id].class.should eq(Fixnum)
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'return containing Hashes with tree_id' do
|
166
|
+
@transitions.first[:tree_id].class.should eq(Fixnum)
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'return containing Hashes with node_name' do
|
170
|
+
@transitions.first[:node_name].class.should eq(String)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
context '#transitions for many' do
|
175
|
+
before do
|
176
|
+
VCR.use_cassette('transitions/many') do
|
177
|
+
@transitions = @client.transitions(@current_tree_id)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'return an Array' do
|
182
|
+
@transitions.class.should eq(Array)
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'return multiple' do
|
186
|
+
@transitions.size.should eq(6)
|
187
|
+
end
|
188
|
+
|
189
|
+
it 'return containing Hashes' do
|
190
|
+
@transitions.first.class.should eq(Hash)
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'return containing Hashes with product_id' do
|
194
|
+
@transitions.first[:product_id].class.should eq(Fixnum)
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'return containing Hashes with tree_id' do
|
198
|
+
@transitions.first[:tree_id].class.should eq(Fixnum)
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'return containing Hashes with node_name' do
|
202
|
+
@transitions.first[:node_name].class.should eq(String)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
context '#upgrade' do
|
207
|
+
before do
|
208
|
+
VCR.use_cassette('upgrade/default') do
|
209
|
+
@result = @client.upgrade(@upgrade_tree_id)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'require target_tree_id non-nil' do
|
214
|
+
expect { @client.upgrade(nil) }.to raise_error(ArgumentError)
|
215
|
+
end
|
216
|
+
|
217
|
+
it 'require target_tree_id non-blank' do
|
218
|
+
expect { @client.upgrade('') }.to raise_error(ArgumentError)
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'raise RubyEcommError for unknown resource_type' do
|
222
|
+
VCR.use_cassette('upgrade/unknown/resource_type') do
|
223
|
+
@client.resource_type = 'flugel'
|
224
|
+
expect { @client.upgrade(@upgrade_tree_id) }.to raise_error(RubyEcommError){|e| e.result_code.should eq(-100) }
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
it 'raise RubyEcommError for unknown resource_id' do
|
229
|
+
VCR.use_cassette('upgrade/unknown/resource_id') do
|
230
|
+
@client.resource_id = 'unknown'
|
231
|
+
expect { @client.upgrade(@upgrade_tree_id) }.to raise_error(RubyEcommError){|e| e.result_code.should eq(-304) }
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'raise RubyEcommError for unknown target_tree_id' do
|
236
|
+
VCR.use_cassette('upgrade/unknown/target_tree_id') do
|
237
|
+
expect { @client.upgrade(73223) }.to raise_error(RubyEcommError){|e| e.result_code.should eq(-999) }
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
it "return no-op request_result for transition to same" do
|
242
|
+
VCR.use_cassette('upgrade/noop') do
|
243
|
+
@client.upgrade(@current_tree_id).should eq(1)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
it "return success request_result for valid transition" do
|
248
|
+
@result.should eq(2)
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
context '#downgrade' do
|
253
|
+
before do
|
254
|
+
VCR.use_cassette('downgrade/default') do
|
255
|
+
@result = @client.downgrade(@downgrade_tree_id)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'require target_tree_id non-nil' do
|
260
|
+
expect { @client.downgrade(nil) }.to raise_error(ArgumentError)
|
261
|
+
end
|
262
|
+
|
263
|
+
it 'require target_tree_id non-blank' do
|
264
|
+
expect { @client.downgrade('') }.to raise_error(ArgumentError)
|
265
|
+
end
|
266
|
+
|
267
|
+
it 'raise RubyEcommError for unknown resource_type' do
|
268
|
+
VCR.use_cassette('downgrade/unknown/resource_type') do
|
269
|
+
@client.resource_type = 'flugel'
|
270
|
+
expect { @client.downgrade(@downgrade_tree_id) }.to raise_error(RubyEcommError){|e| e.result_code.should eq(-100) }
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
it 'raise RubyEcommError for unknown resource_id' do
|
275
|
+
VCR.use_cassette('downgrade/unknown/resource_id') do
|
276
|
+
@client.resource_id = 'unknown'
|
277
|
+
expect { @client.downgrade(@downgrade_tree_id) }.to raise_error(RubyEcommError){|e| e.result_code.should eq(-304) }
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
it 'raise RubyEcommError for unknown target_tree_id' do
|
282
|
+
VCR.use_cassette('downgrade/unknown/target_tree_id') do
|
283
|
+
expect { @client.downgrade(73541) }.to raise_error(RubyEcommError){|e| e.result_code.should eq(-999) }
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
it "return no-op request_result for transition to same" do
|
288
|
+
VCR.use_cassette('downgrade/noop') do
|
289
|
+
@client.downgrade(@current_tree_id).should eq(1)
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
it "return success request_result for valid transition" do
|
294
|
+
@result.should eq(2)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|