braintree-rails 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.travis.yml +13 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile +3 -4
- data/Gemfile.lock +33 -14
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/braintree-rails.gemspec +4 -5
- data/lib/braintree_rails/address.rb +1 -1
- data/lib/braintree_rails/address_details.rb +14 -0
- data/lib/braintree_rails/address_details_validator.rb +7 -0
- data/lib/braintree_rails/association.rb +2 -2
- data/lib/braintree_rails/braintree_ext.rb +27 -1
- data/lib/braintree_rails/business_details.rb +29 -0
- data/lib/braintree_rails/business_details_validator.rb +12 -0
- data/lib/braintree_rails/configuration.rb +1 -1
- data/lib/braintree_rails/credit_card.rb +6 -6
- data/lib/braintree_rails/credit_card_validator.rb +2 -17
- data/lib/braintree_rails/customer.rb +6 -6
- data/lib/braintree_rails/customer_validator.rb +1 -12
- data/lib/braintree_rails/funding_details.rb +17 -0
- data/lib/braintree_rails/funding_details_validator.rb +10 -0
- data/lib/braintree_rails/individual_details.rb +32 -0
- data/lib/braintree_rails/individual_details_validator.rb +11 -0
- data/lib/braintree_rails/merchant_account.rb +45 -0
- data/lib/braintree_rails/merchant_account_validator.rb +14 -0
- data/lib/braintree_rails/plan.rb +3 -3
- data/lib/braintree_rails/subscription.rb +5 -5
- data/lib/braintree_rails/transaction.rb +9 -9
- data/lib/braintree_rails/transaction_validator.rb +1 -5
- data/lib/braintree_rails/validator.rb +13 -0
- data/lib/braintree_rails/version.rb +1 -1
- data/lib/tasks/ci.rake +7 -0
- data/lib/tasks/spec.rake +18 -0
- data/lib/test_env.rb +1 -7
- data/{test → spec}/config/braintree_auth.yml.example +0 -0
- data/{test → spec}/fixtures/add_ons.xml +0 -0
- data/{test → spec}/fixtures/address.xml +0 -0
- data/{test → spec}/fixtures/credit_card.xml +0 -0
- data/{test → spec}/fixtures/credit_card_validation_error.xml +0 -0
- data/{test → spec}/fixtures/customer.xml +0 -0
- data/{test → spec}/fixtures/discounts.xml +0 -0
- data/spec/fixtures/merchant_account.xml +7 -0
- data/{test → spec}/fixtures/plans.xml +0 -0
- data/{test → spec}/fixtures/subscription.xml +0 -0
- data/{test → spec}/fixtures/subscription_ids.xml +0 -0
- data/{test → spec}/fixtures/subscriptions.xml +0 -0
- data/{test → spec}/fixtures/transaction.xml +0 -0
- data/{test → spec}/fixtures/transaction_error.xml +0 -0
- data/{test → spec}/fixtures/transaction_ids.xml +0 -0
- data/{test → spec}/fixtures/transactions.xml +0 -0
- data/{test/integration/braintree_rails/address_integration_test.rb → spec/integration/braintree_rails/address_integration_spec.rb} +8 -8
- data/{test/integration/braintree_rails/credit_card_integration_test.rb → spec/integration/braintree_rails/credit_card_integration_spec.rb} +20 -20
- data/{test/integration/braintree_rails/customer_integration_test.rb → spec/integration/braintree_rails/customer_integration_spec.rb} +20 -20
- data/spec/integration/braintree_rails/merchant_account_integration_spec.rb +37 -0
- data/{test/integration/braintree_rails/transaction_integration_test.rb → spec/integration/braintree_rails/transaction_integration_spec.rb} +27 -27
- data/spec/integration/integration_spec_helper.rb +23 -0
- data/spec/spec_helper.rb +17 -0
- data/{test/test_helper.rb → spec/support/helper.rb} +42 -21
- data/spec/support/string_ext.rb +5 -0
- data/{test/unit/braintree_rails/add_on_test.rb → spec/unit/braintree_rails/add_on_spec.rb} +10 -10
- data/{test/unit/braintree_rails/add_ons_test.rb → spec/unit/braintree_rails/add_ons_spec.rb} +4 -4
- data/spec/unit/braintree_rails/address_details_spec.rb +13 -0
- data/{test/unit/braintree_rails/address_test.rb → spec/unit/braintree_rails/address_spec.rb} +26 -26
- data/{test/unit/braintree_rails/addresses_test.rb → spec/unit/braintree_rails/addresses_spec.rb} +7 -7
- data/spec/unit/braintree_rails/business_details_spec.rb +28 -0
- data/{test/unit/braintree_rails/configuration_test.rb → spec/unit/braintree_rails/configuration_spec.rb} +6 -6
- data/{test/unit/braintree_rails/credit_card_test.rb → spec/unit/braintree_rails/credit_card_spec.rb} +78 -72
- data/{test/unit/braintree_rails/credit_cards_test.rb → spec/unit/braintree_rails/credit_cards_spec.rb} +15 -10
- data/{test/unit/braintree_rails/customer_test.rb → spec/unit/braintree_rails/customer_spec.rb} +46 -46
- data/{test/unit/braintree_rails/discount_test.rb → spec/unit/braintree_rails/discount_spec.rb} +10 -10
- data/{test/unit/braintree_rails/discounts_test.rb → spec/unit/braintree_rails/discounts_spec.rb} +4 -4
- data/spec/unit/braintree_rails/funding_details_spec.rb +36 -0
- data/spec/unit/braintree_rails/individual_details_spec.rb +19 -0
- data/{test/unit/braintree_rails/luhn_10_validator_test.rb → spec/unit/braintree_rails/luhn_10_validator_spec.rb} +5 -5
- data/spec/unit/braintree_rails/merchant_account_spec.rb +50 -0
- data/{test/unit/braintree_rails/plan_test.rb → spec/unit/braintree_rails/plan_spec.rb} +12 -12
- data/{test/unit/braintree_rails/subscription_test.rb → spec/unit/braintree_rails/subscription_spec.rb} +55 -55
- data/{test/unit/braintree_rails/subscriptions_test.rb → spec/unit/braintree_rails/subscriptions_spec.rb} +4 -4
- data/{test/unit/braintree_rails/transaction_test.rb → spec/unit/braintree_rails/transaction_spec.rb} +55 -55
- data/{test/unit/braintree_rails/transactions_test.rb → spec/unit/braintree_rails/transactions_spec.rb} +9 -9
- data/{test/unit/braintree_rails/validation_error_test.rb → spec/unit/braintree_rails/validation_error_spec.rb} +4 -4
- data/{test/unit/braintree_rails/validator_test.rb → spec/unit/braintree_rails/validator_spec.rb} +7 -7
- data/spec/unit/unit_spec_helper.rb +4 -0
- metadata +69 -63
- data/lib/tasks/test.rake +0 -18
- data/test/integration/integration_test_helper.rb +0 -13
- data/test/unit/unit_test_helper.rb +0 -3
data/{test/unit/braintree_rails/transaction_test.rb → spec/unit/braintree_rails/transaction_spec.rb}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '../
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../unit_spec_helper'))
|
2
2
|
|
3
3
|
describe BraintreeRails::Transaction do
|
4
4
|
before do
|
@@ -12,9 +12,9 @@ describe BraintreeRails::Transaction do
|
|
12
12
|
braintree_transaction = Braintree::Transaction.find('transactionid')
|
13
13
|
transaction = BraintreeRails::Transaction.new('transactionid')
|
14
14
|
|
15
|
-
transaction.
|
15
|
+
transaction.should be_persisted
|
16
16
|
[:amount, :created_at, :updated_at].each do |attribute|
|
17
|
-
transaction.send(attribute).
|
17
|
+
transaction.send(attribute).should == braintree_transaction.send(attribute)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -22,28 +22,28 @@ describe BraintreeRails::Transaction do
|
|
22
22
|
braintree_transaction = Braintree::Transaction.find('transactionid')
|
23
23
|
transaction = BraintreeRails::Transaction.new(braintree_transaction)
|
24
24
|
|
25
|
-
transaction.
|
25
|
+
transaction.should be_persisted
|
26
26
|
[:amount, :created_at, :updated_at].each do |attribute|
|
27
|
-
transaction.send(attribute).
|
27
|
+
transaction.send(attribute).should == braintree_transaction.send(attribute)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should extract values from hash' do
|
32
32
|
transaction = BraintreeRails::Transaction.new(:id => 'new_id')
|
33
33
|
|
34
|
-
transaction.
|
35
|
-
transaction.id.
|
34
|
+
transaction.should_not be_persisted
|
35
|
+
transaction.id.should == 'new_id'
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should try to extract value from other types' do
|
39
39
|
transaction = BraintreeRails::Transaction.new(OpenStruct.new(:id => 'foobar', :amount => '10.00', :persisted? => true))
|
40
40
|
|
41
|
-
transaction.
|
42
|
-
transaction.id.
|
43
|
-
transaction.amount.
|
41
|
+
transaction.should be_persisted
|
42
|
+
transaction.id.should == 'foobar'
|
43
|
+
transaction.amount.should == '10.00'
|
44
44
|
|
45
45
|
transaction = BraintreeRails::Transaction.new(Object.new)
|
46
|
-
transaction.
|
46
|
+
transaction.should_not be_persisted
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -51,12 +51,12 @@ describe BraintreeRails::Transaction do
|
|
51
51
|
describe association do
|
52
52
|
it "should load #{association} for persisted transaction" do
|
53
53
|
transaction = BraintreeRails::Transaction.new('transactionid')
|
54
|
-
transaction.send(association).
|
54
|
+
transaction.send(association).should be_persisted
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should keep #{association} nil if assigned nil value" do
|
58
58
|
transaction = BraintreeRails::Transaction.new(association => nil)
|
59
|
-
transaction.send(association).
|
59
|
+
transaction.send(association).should be_nil
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -67,8 +67,8 @@ describe BraintreeRails::Transaction do
|
|
67
67
|
braintree_transaction = Braintree::Transaction.find('transactionid')
|
68
68
|
transaction = BraintreeRails::Transaction.new(braintree_transaction)
|
69
69
|
|
70
|
-
transaction.send(association).
|
71
|
-
transaction.send(association).size.
|
70
|
+
transaction.send(association).should respond_to(:each)
|
71
|
+
transaction.send(association).size.should == braintree_transaction.send(association).size
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -77,63 +77,63 @@ describe BraintreeRails::Transaction do
|
|
77
77
|
it 'should validate amount' do
|
78
78
|
[nil, 'abc', -1].each do |invalid_value|
|
79
79
|
transaction = BraintreeRails::Transaction.new(:amount => invalid_value)
|
80
|
-
transaction.
|
81
|
-
transaction.errors[:amount].
|
80
|
+
transaction.should_not be_valid
|
81
|
+
transaction.errors[:amount].should_not be_blank
|
82
82
|
end
|
83
83
|
|
84
84
|
[10, 10.0, "10", "10.00"].each do |valid_value|
|
85
85
|
transaction = BraintreeRails::Transaction.new(:amount => valid_value)
|
86
86
|
transaction.valid?
|
87
|
-
transaction.errors[:amount].
|
87
|
+
transaction.errors[:amount].should be_blank
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'should validate type' do
|
92
92
|
['refund', 'abc'].each do |invalid_value|
|
93
93
|
transaction = BraintreeRails::Transaction.new(:type => invalid_value)
|
94
|
-
transaction.
|
95
|
-
transaction.errors[:type].
|
94
|
+
transaction.should_not be_valid
|
95
|
+
transaction.errors[:type].should_not be_blank
|
96
96
|
end
|
97
97
|
|
98
98
|
['sale', 'credit'].each do |valid_value|
|
99
99
|
transaction = BraintreeRails::Transaction.new(:type => valid_value)
|
100
100
|
transaction.valid?
|
101
|
-
transaction.errors[:type].
|
101
|
+
transaction.errors[:type].should be_blank
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
105
|
describe 'credit card' do
|
106
106
|
it 'is valid if new credit card with valid billing address' do
|
107
107
|
transaction = BraintreeRails::Transaction.new(:amount => 10, :billing => address_hash, :credit_card => credit_card_hash)
|
108
|
-
transaction.
|
108
|
+
transaction.should be_valid
|
109
109
|
|
110
110
|
transaction = BraintreeRails::Transaction.new(:amount => 10, :credit_card => credit_card_hash)
|
111
|
-
transaction.
|
111
|
+
transaction.should_not be_valid
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'is valid if credit card is persisted' do
|
115
115
|
transaction = BraintreeRails::Transaction.new(:amount => 10, :credit_card => BraintreeRails::CreditCard.find('credit_card_id'))
|
116
|
-
transaction.
|
116
|
+
transaction.should be_valid
|
117
117
|
end
|
118
118
|
|
119
119
|
it 'is valid if customer has default credit card' do
|
120
120
|
transaction = BraintreeRails::Transaction.new(:amount => 10, :customer => BraintreeRails::Customer.find('customer_id'))
|
121
|
-
transaction.
|
121
|
+
transaction.should be_valid
|
122
122
|
|
123
123
|
transaction = BraintreeRails::Transaction.new(:amount => 10, :customer => customer_hash)
|
124
|
-
transaction.
|
124
|
+
transaction.should_not be_valid
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'should not validate credit card if already persisted' do
|
128
128
|
transaction = BraintreeRails::Transaction.new(OpenStruct.new(:amount => 10, :persisted? => true))
|
129
|
-
transaction.
|
129
|
+
transaction.should be_valid
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
134
|
describe '#attribute_for_create' do
|
135
135
|
it 'should default type to sale' do
|
136
|
-
BraintreeRails::Transaction.new.send(:attributes_for, :create)
|
136
|
+
BraintreeRails::Transaction.new.send(:attributes_for, :create)[:type].should == 'sale'
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -147,75 +147,75 @@ describe BraintreeRails::Transaction do
|
|
147
147
|
credit_card = BraintreeRails::CreditCard.find('credit_card_id')
|
148
148
|
transaction = BraintreeRails::Transaction.new(:amount => '10.00', :customer => customer, :credit_card => credit_card)
|
149
149
|
|
150
|
-
transaction.save.
|
151
|
-
transaction.status.
|
150
|
+
transaction.save.should be_true
|
151
|
+
transaction.status.should == Braintree::Transaction::Status::Authorized
|
152
152
|
end
|
153
153
|
|
154
154
|
it 'should create a sale transaction from new credit card' do
|
155
155
|
transaction = BraintreeRails::Transaction.new(:amount => '10.00', :billing => address_hash, :credit_card => credit_card_hash)
|
156
156
|
transaction.valid?
|
157
|
-
transaction.save.
|
158
|
-
transaction.status.
|
157
|
+
transaction.save.should be_true
|
158
|
+
transaction.status.should == Braintree::Transaction::Status::Authorized
|
159
159
|
end
|
160
160
|
|
161
161
|
it 'should clear encrypted attributes even when save failed' do
|
162
162
|
transaction = BraintreeRails::Transaction.new(:amount => 'foo', :credit_card => credit_card_hash)
|
163
|
-
transaction.save.
|
164
|
-
transaction.credit_card.number.
|
163
|
+
transaction.save.should be_false
|
164
|
+
transaction.credit_card.number.should be_blank
|
165
165
|
end
|
166
166
|
|
167
167
|
it 'should clear encrypted attributes after save' do
|
168
168
|
transaction = BraintreeRails::Transaction.new(:amount => '10.00', :billing => address_hash, :credit_card => credit_card_hash)
|
169
169
|
transaction.valid?
|
170
|
-
transaction.save.
|
171
|
-
transaction.credit_card.number.
|
170
|
+
transaction.save.should be_true
|
171
|
+
transaction.credit_card.number.should be_blank
|
172
172
|
end
|
173
173
|
|
174
174
|
it 'should clear encrypted attributes' do
|
175
175
|
transaction = BraintreeRails::Transaction.new(:credit_card => credit_card_hash)
|
176
176
|
transaction.clear_encryped_attributes
|
177
|
-
transaction.credit_card.number.
|
177
|
+
transaction.credit_card.number.should be_blank
|
178
178
|
end
|
179
179
|
|
180
180
|
it 'should use default credit card of customer if credit_card is not specified' do
|
181
181
|
customer = BraintreeRails::Customer.find('customer_id')
|
182
182
|
transaction = BraintreeRails::Transaction.new(:amount => '10.00', :customer => customer)
|
183
|
-
transaction.save.
|
184
|
-
transaction.status.
|
183
|
+
transaction.save.should be_true
|
184
|
+
transaction.status.should == Braintree::Transaction::Status::Authorized
|
185
185
|
end
|
186
186
|
|
187
187
|
it "should be able to submit_for_settlement a authorized transaction" do
|
188
188
|
transaction = BraintreeRails::Transaction.find('transactionid')
|
189
189
|
stub_braintree_request(:put, "/transactions/#{transaction.id}/submit_for_settlement", :body => fixture('transaction.xml'))
|
190
|
-
transaction.submit_for_settlement.
|
190
|
+
transaction.submit_for_settlement.should be_true
|
191
191
|
transaction.status = Braintree::Transaction::Status::Settled
|
192
|
-
transaction.submit_for_settlement.
|
192
|
+
transaction.submit_for_settlement.should be_false
|
193
193
|
end
|
194
194
|
|
195
195
|
it "should be able to refund a settled transaction" do
|
196
196
|
transaction = BraintreeRails::Transaction.find('transactionid')
|
197
197
|
transaction.status = Braintree::Transaction::Status::Settled
|
198
198
|
stub_braintree_request(:post, "/transactions/#{transaction.id}/refund", :body => fixture('transaction.xml'))
|
199
|
-
transaction.refund.
|
199
|
+
transaction.refund.should be_true
|
200
200
|
transaction.status = Braintree::Transaction::Status::Authorized
|
201
|
-
transaction.refund.
|
201
|
+
transaction.refund.should be_false
|
202
202
|
end
|
203
203
|
|
204
204
|
it "should be able to void a authorized transaction" do
|
205
205
|
transaction = BraintreeRails::Transaction.find('transactionid')
|
206
206
|
stub_braintree_request(:put, "/transactions/#{transaction.id}/void", :body => fixture('transaction.xml'))
|
207
|
-
transaction.void.
|
207
|
+
transaction.void.should be_true
|
208
208
|
transaction.status = Braintree::Transaction::Status::Settled
|
209
|
-
transaction.void.
|
209
|
+
transaction.void.should be_false
|
210
210
|
end
|
211
211
|
|
212
212
|
it 'should show errors when trying to submit already voided transaction' do
|
213
213
|
transaction = BraintreeRails::Transaction.find('transactionid')
|
214
214
|
transaction.status = Braintree::Transaction::Status::Voided
|
215
|
-
transaction.submit_for_settlement.
|
216
|
-
transaction.errors[:status].
|
215
|
+
transaction.submit_for_settlement.should be_false
|
216
|
+
transaction.errors[:status].should_not be_blank
|
217
217
|
|
218
|
-
|
218
|
+
expect {transaction.submit_for_settlement!}.to raise_error(BraintreeRails::RecordInvalid)
|
219
219
|
end
|
220
220
|
|
221
221
|
it 'should propergate api errors to credit card if any' do
|
@@ -224,16 +224,16 @@ describe BraintreeRails::Transaction do
|
|
224
224
|
transaction = BraintreeRails::Transaction.new(:amount => '10.00', :customer => customer, :credit_card => credit_card)
|
225
225
|
stub_braintree_request(:post, '/transactions', :status => 422, :body => fixture('transaction_error.xml'))
|
226
226
|
transaction.save
|
227
|
-
transaction.errors[:base].
|
228
|
-
transaction.credit_card.errors.full_messages.
|
229
|
-
transaction.credit_card.errors[:number].first.code.
|
230
|
-
transaction.credit_card.errors[:number].first.message.
|
231
|
-
transaction.credit_card.errors[:number].first.to_s.
|
227
|
+
transaction.errors[:base].should == ["Credit card type is not accepted by this merchant account."]
|
228
|
+
transaction.credit_card.errors.full_messages.should == ["Number Credit card number is invalid."]
|
229
|
+
transaction.credit_card.errors[:number].first.code.should == "81715"
|
230
|
+
transaction.credit_card.errors[:number].first.message.should == "Credit card number is invalid."
|
231
|
+
transaction.credit_card.errors[:number].first.to_s.should == "Credit card number is invalid."
|
232
232
|
end
|
233
233
|
|
234
234
|
it 'does not support update or destroy' do
|
235
|
-
|
236
|
-
|
235
|
+
expect {BraintreeRails::Transaction.find('transactionid').update_attributes(:amount => 1)}.to raise_error(BraintreeRails::NotSupportedApiException)
|
236
|
+
expect {BraintreeRails::Transaction.find('transactionid').destroy!}.to raise_error(BraintreeRails::NotSupportedApiException)
|
237
237
|
end
|
238
238
|
end
|
239
239
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '../
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../unit_spec_helper'))
|
2
2
|
|
3
3
|
describe BraintreeRails::Transactions do
|
4
4
|
|
@@ -19,7 +19,7 @@ describe BraintreeRails::Transactions do
|
|
19
19
|
|
20
20
|
transactions = BraintreeRails::Transactions.new(BraintreeRails::Customer.new('customer_id'))
|
21
21
|
|
22
|
-
transactions.map(&:id).sort.
|
22
|
+
transactions.map(&:id).sort.should == braintree_transactions.map(&:id).sort
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should load all transactions' do
|
@@ -28,7 +28,7 @@ describe BraintreeRails::Transactions do
|
|
28
28
|
|
29
29
|
braintree_transactions = Braintree::Transaction.search
|
30
30
|
transactions = BraintreeRails::Transactions.new(nil)
|
31
|
-
transactions.map(&:id).sort.
|
31
|
+
transactions.map(&:id).sort.should == braintree_transactions.map(&:id).sort
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -39,27 +39,27 @@ describe BraintreeRails::Transactions do
|
|
39
39
|
customer = BraintreeRails::Customer.new('customer_id')
|
40
40
|
transactions = BraintreeRails::Transactions.new(customer)
|
41
41
|
transaction = transactions.build
|
42
|
-
transaction.customer.
|
43
|
-
transaction.credit_card.
|
42
|
+
transaction.customer.should == customer
|
43
|
+
transaction.credit_card.should == customer.credit_cards.find(&:default?)
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'has no default options when loading all' do
|
47
47
|
transactions = BraintreeRails::Transactions.new(nil)
|
48
48
|
transaction = transactions.build
|
49
|
-
transaction.attributes.except(:type).values.compact.
|
49
|
+
transaction.attributes.except(:type).values.compact.should be_empty
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'should be able to override default values' do
|
53
53
|
transactions = BraintreeRails::Transactions.new(BraintreeRails::Customer.new('customer_id'))
|
54
54
|
customer = BraintreeRails::Customer.new(:first_name => 'Braintree')
|
55
55
|
transaction = transactions.build(:customer => customer)
|
56
|
-
transaction.customer.
|
56
|
+
transaction.customer.should == customer
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
describe '#lazy_loading' do
|
61
61
|
it 'should not load if not necessary' do
|
62
|
-
|
62
|
+
expect {BraintreeRails::Transactions.new(BraintreeRails::Customer.new('customer_id'))}.not_to raise_error()
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'load from Braintree when needed' do
|
@@ -67,7 +67,7 @@ describe BraintreeRails::Transactions do
|
|
67
67
|
stub_braintree_request(:post, '/transactions/advanced_search_ids', :body => fixture('transaction_ids.xml'))
|
68
68
|
stub_braintree_request(:post, '/transactions/advanced_search', :body => fixture('transactions.xml'))
|
69
69
|
|
70
|
-
transactions.find('transactionid').
|
70
|
+
transactions.find('transactionid').should_not be_blank
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '../
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../unit_spec_helper'))
|
2
2
|
|
3
3
|
describe BraintreeRails::ApiError do
|
4
4
|
describe "#to_s" do
|
5
5
|
it "shows only the message" do
|
6
|
-
BraintreeRails::ApiError.new("error_message", "error code").to_s.
|
6
|
+
BraintreeRails::ApiError.new("error_message", "error code").to_s.should == 'error_message'
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "#inspect" do
|
11
11
|
it "shows only the message" do
|
12
|
-
BraintreeRails::ApiError.new("error_message", "error code").inspect.
|
12
|
+
BraintreeRails::ApiError.new("error_message", "error code").inspect.should == '#<BraintreeRails::ApiError (error code) error_message>'
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "#empty?" do
|
17
17
|
it "delegate to message" do
|
18
18
|
["", "abc"].each do |message|
|
19
|
-
BraintreeRails::ApiError.new(message, "error code").empty?.
|
19
|
+
BraintreeRails::ApiError.new(message, "error code").empty?.should == message.empty?
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/{test/unit/braintree_rails/validator_test.rb → spec/unit/braintree_rails/validator_spec.rb}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '../
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../unit_spec_helper'))
|
2
2
|
|
3
3
|
describe BraintreeRails::Validator do
|
4
4
|
describe "setup" do
|
@@ -6,10 +6,10 @@ describe BraintreeRails::Validator do
|
|
6
6
|
begin
|
7
7
|
customer = BraintreeRails::Customer.new(:id => '%')
|
8
8
|
customer.valid?
|
9
|
-
customer.errors[:id].
|
9
|
+
customer.errors[:id].should_not be_blank
|
10
10
|
|
11
11
|
BraintreeRails::CustomerValidator.setup {[]}
|
12
|
-
customer.
|
12
|
+
customer.should be_valid
|
13
13
|
ensure
|
14
14
|
BraintreeRails::CustomerValidator.setup
|
15
15
|
end
|
@@ -22,10 +22,10 @@ describe BraintreeRails::Validator do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
customer = BraintreeRails::Customer.new(:id => '%')
|
25
|
-
customer.
|
26
|
-
customer.valid?(:create).
|
27
|
-
customer.save.
|
28
|
-
customer.errors[:id].
|
25
|
+
customer.should be_valid
|
26
|
+
customer.valid?(:create).should be_false
|
27
|
+
customer.save.should be_false
|
28
|
+
customer.errors[:id].should_not be_blank
|
29
29
|
ensure
|
30
30
|
BraintreeRails::CustomerValidator.setup
|
31
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: braintree-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lin Yang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: braintree
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.28.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.28.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '>='
|
@@ -95,21 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - '>='
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - '>='
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: simplecov
|
98
|
+
name: coveralls
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
101
|
- - '>='
|
@@ -141,6 +127,8 @@ files:
|
|
141
127
|
- lib/braintree_rails/add_on.rb
|
142
128
|
- lib/braintree_rails/add_ons.rb
|
143
129
|
- lib/braintree_rails/address.rb
|
130
|
+
- lib/braintree_rails/address_details.rb
|
131
|
+
- lib/braintree_rails/address_details_validator.rb
|
144
132
|
- lib/braintree_rails/address_validator.rb
|
145
133
|
- lib/braintree_rails/addresses.rb
|
146
134
|
- lib/braintree_rails/api_error.rb
|
@@ -151,6 +139,8 @@ files:
|
|
151
139
|
- lib/braintree_rails/billing_address_validator.rb
|
152
140
|
- lib/braintree_rails/braintree_ext.rb
|
153
141
|
- lib/braintree_rails/braintree_rails.rb
|
142
|
+
- lib/braintree_rails/business_details.rb
|
143
|
+
- lib/braintree_rails/business_details_validator.rb
|
154
144
|
- lib/braintree_rails/collection_association.rb
|
155
145
|
- lib/braintree_rails/configuration.rb
|
156
146
|
- lib/braintree_rails/credit_card.rb
|
@@ -161,7 +151,13 @@ files:
|
|
161
151
|
- lib/braintree_rails/discount.rb
|
162
152
|
- lib/braintree_rails/discounts.rb
|
163
153
|
- lib/braintree_rails/exceptions.rb
|
154
|
+
- lib/braintree_rails/funding_details.rb
|
155
|
+
- lib/braintree_rails/funding_details_validator.rb
|
156
|
+
- lib/braintree_rails/individual_details.rb
|
157
|
+
- lib/braintree_rails/individual_details_validator.rb
|
164
158
|
- lib/braintree_rails/luhn10_validator.rb
|
159
|
+
- lib/braintree_rails/merchant_account.rb
|
160
|
+
- lib/braintree_rails/merchant_account_validator.rb
|
165
161
|
- lib/braintree_rails/model.rb
|
166
162
|
- lib/braintree_rails/modification.rb
|
167
163
|
- lib/braintree_rails/modification_validator.rb
|
@@ -182,49 +178,59 @@ files:
|
|
182
178
|
- lib/braintree_rails/validator.rb
|
183
179
|
- lib/braintree_rails/version.rb
|
184
180
|
- lib/env.rb
|
185
|
-
- lib/tasks/
|
181
|
+
- lib/tasks/ci.rake
|
182
|
+
- lib/tasks/spec.rake
|
186
183
|
- lib/test_env.rb
|
187
184
|
- log/.gitignore
|
188
|
-
-
|
189
|
-
-
|
190
|
-
-
|
191
|
-
-
|
192
|
-
-
|
193
|
-
-
|
194
|
-
-
|
195
|
-
-
|
196
|
-
-
|
197
|
-
-
|
198
|
-
-
|
199
|
-
-
|
200
|
-
-
|
201
|
-
-
|
202
|
-
-
|
203
|
-
-
|
204
|
-
-
|
205
|
-
-
|
206
|
-
-
|
207
|
-
-
|
208
|
-
-
|
209
|
-
-
|
210
|
-
-
|
211
|
-
-
|
212
|
-
-
|
213
|
-
-
|
214
|
-
-
|
215
|
-
-
|
216
|
-
-
|
217
|
-
-
|
218
|
-
-
|
219
|
-
-
|
220
|
-
-
|
221
|
-
-
|
222
|
-
-
|
223
|
-
-
|
224
|
-
-
|
225
|
-
-
|
226
|
-
-
|
227
|
-
-
|
185
|
+
- spec/config/braintree_auth.yml.example
|
186
|
+
- spec/fixtures/add_ons.xml
|
187
|
+
- spec/fixtures/address.xml
|
188
|
+
- spec/fixtures/credit_card.xml
|
189
|
+
- spec/fixtures/credit_card_validation_error.xml
|
190
|
+
- spec/fixtures/customer.xml
|
191
|
+
- spec/fixtures/discounts.xml
|
192
|
+
- spec/fixtures/merchant_account.xml
|
193
|
+
- spec/fixtures/plans.xml
|
194
|
+
- spec/fixtures/subscription.xml
|
195
|
+
- spec/fixtures/subscription_ids.xml
|
196
|
+
- spec/fixtures/subscriptions.xml
|
197
|
+
- spec/fixtures/transaction.xml
|
198
|
+
- spec/fixtures/transaction_error.xml
|
199
|
+
- spec/fixtures/transaction_ids.xml
|
200
|
+
- spec/fixtures/transactions.xml
|
201
|
+
- spec/integration/braintree_rails/address_integration_spec.rb
|
202
|
+
- spec/integration/braintree_rails/credit_card_integration_spec.rb
|
203
|
+
- spec/integration/braintree_rails/customer_integration_spec.rb
|
204
|
+
- spec/integration/braintree_rails/merchant_account_integration_spec.rb
|
205
|
+
- spec/integration/braintree_rails/transaction_integration_spec.rb
|
206
|
+
- spec/integration/integration_spec_helper.rb
|
207
|
+
- spec/spec_helper.rb
|
208
|
+
- spec/support/helper.rb
|
209
|
+
- spec/support/string_ext.rb
|
210
|
+
- spec/unit/braintree_rails/add_on_spec.rb
|
211
|
+
- spec/unit/braintree_rails/add_ons_spec.rb
|
212
|
+
- spec/unit/braintree_rails/address_details_spec.rb
|
213
|
+
- spec/unit/braintree_rails/address_spec.rb
|
214
|
+
- spec/unit/braintree_rails/addresses_spec.rb
|
215
|
+
- spec/unit/braintree_rails/business_details_spec.rb
|
216
|
+
- spec/unit/braintree_rails/configuration_spec.rb
|
217
|
+
- spec/unit/braintree_rails/credit_card_spec.rb
|
218
|
+
- spec/unit/braintree_rails/credit_cards_spec.rb
|
219
|
+
- spec/unit/braintree_rails/customer_spec.rb
|
220
|
+
- spec/unit/braintree_rails/discount_spec.rb
|
221
|
+
- spec/unit/braintree_rails/discounts_spec.rb
|
222
|
+
- spec/unit/braintree_rails/funding_details_spec.rb
|
223
|
+
- spec/unit/braintree_rails/individual_details_spec.rb
|
224
|
+
- spec/unit/braintree_rails/luhn_10_validator_spec.rb
|
225
|
+
- spec/unit/braintree_rails/merchant_account_spec.rb
|
226
|
+
- spec/unit/braintree_rails/plan_spec.rb
|
227
|
+
- spec/unit/braintree_rails/subscription_spec.rb
|
228
|
+
- spec/unit/braintree_rails/subscriptions_spec.rb
|
229
|
+
- spec/unit/braintree_rails/transaction_spec.rb
|
230
|
+
- spec/unit/braintree_rails/transactions_spec.rb
|
231
|
+
- spec/unit/braintree_rails/validation_error_spec.rb
|
232
|
+
- spec/unit/braintree_rails/validator_spec.rb
|
233
|
+
- spec/unit/unit_spec_helper.rb
|
228
234
|
homepage: https://github.com/lyang/braintree-rails
|
229
235
|
licenses:
|
230
236
|
- MIT
|
@@ -245,9 +251,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
245
251
|
version: '0'
|
246
252
|
requirements: []
|
247
253
|
rubyforge_project:
|
248
|
-
rubygems_version: 2.
|
254
|
+
rubygems_version: 2.1.11
|
249
255
|
signing_key:
|
250
256
|
specification_version: 4
|
251
257
|
summary: Provides ActiveModel compatible wrappers for Braintree models.
|
252
258
|
test_files:
|
253
|
-
-
|
259
|
+
- spec/spec_helper.rb
|