blob: ca89e65fe0dcf60ca708be9af1de1e9b6b82ccb8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
require 'test_helper'
require 'fake_braintree'
class CustomerWithPaymentInfoTest < ActiveSupport::TestCase
setup do
@customer = FactoryGirl.build(:customer_with_payment_info)
end
test "has payment_info" do
assert @customer.braintree_customer_id
assert @customer.has_payment_info?
end
test "constructs customer with braintree data" do
@customer.with_braintree_data!
assert_equal 'Big', @customer.first_name
assert_equal 'Spender', @customer.last_name
assert_equal 1, @customer.credit_cards.size
assert_equal Hash.new, @customer.custom_fields
end
test "can access braintree_customer after reload" do
@customer.save
@customer = Customer.find_by_user_id(@customer.user_id)
@customer.with_braintree_data!
assert_equal 'Big', @customer.first_name
assert_equal 'Spender', @customer.last_name
assert_equal 1, @customer.credit_cards.size
assert_equal Hash.new, @customer.custom_fields
end
test "sets default_credit_card" do
@customer.with_braintree_data!
assert_equal @customer.credit_cards.first, @customer.default_credit_card
end
end
|