summaryrefslogtreecommitdiff
path: root/billing/test/unit/customer_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'billing/test/unit/customer_test.rb')
-rw-r--r--billing/test/unit/customer_test.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/billing/test/unit/customer_test.rb b/billing/test/unit/customer_test.rb
new file mode 100644
index 0000000..4ed6392
--- /dev/null
+++ b/billing/test/unit/customer_test.rb
@@ -0,0 +1,38 @@
+require 'test_helper'
+
+class CustomerTest < ActiveSupport::TestCase
+ setup do
+ #cannot get this working with FakeBraintree becuase the methods in customer.rb try to find the customer in braintree itself.
+
+ @user = FactoryGirl.build(:user)
+ @user.save
+ @customer = Customer.new(:user_id => @user.id)
+
+ result = Braintree::Customer.create()
+ @customer.braintree_customer_id = result.customer.id
+ @customer.save
+ @braintree_customer_data = Braintree::Customer.find(@customer.braintree_customer_id)
+
+ result = Braintree::Customer.create(:credit_card => { :number => "5105105105105100", :expiration_date => "05/2012"})
+ end
+
+ teardown do
+ @user.destroy
+ @customer.destroy
+ Braintree::Customer.delete(@customer.braintree_customer_id)
+ end
+
+ test "default credit card" do
+ assert_nil @customer.default_credit_card(@braintree_customer_data)
+ Braintree::Customer.update(@customer.braintree_customer_id, :credit_card => { :number => "5105105105105100", :expiration_date => "05/2012" } )
+ assert_not_nil @customer.default_credit_card
+ assert_equal @customer.default_credit_card.expiration_date, "05/2012"
+ end
+
+
+ test "single subscription" do
+
+
+ end
+
+end