summaryrefslogtreecommitdiff
path: root/billing/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'billing/test/unit')
-rw-r--r--billing/test/unit/customer_test.rb6
-rw-r--r--billing/test/unit/customer_with_payment_info_test.rb27
2 files changed, 27 insertions, 6 deletions
diff --git a/billing/test/unit/customer_test.rb b/billing/test/unit/customer_test.rb
index abcf96a..0358f38 100644
--- a/billing/test/unit/customer_test.rb
+++ b/billing/test/unit/customer_test.rb
@@ -34,10 +34,4 @@ class CustomerTest < ActiveSupport::TestCase
assert_nil @customer.default_credit_card
end
- test "user with braintree id" do
- @customer = FactoryGirl.build(:braintree_customer)
- assert @customer.braintree_customer_id
- assert @customer.has_payment_info?
- end
-
end
diff --git a/billing/test/unit/customer_with_payment_info_test.rb b/billing/test/unit/customer_with_payment_info_test.rb
new file mode 100644
index 0000000..f887674
--- /dev/null
+++ b/billing/test/unit/customer_with_payment_info_test.rb
@@ -0,0 +1,27 @@
+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 "sets default_credit_card" do
+ @customer.with_braintree_data!
+ assert_equal @customer.credit_cards.first, @customer.default_credit_card
+ end
+end