diff options
author | jessib <jessib@leap.se> | 2013-04-30 14:12:08 -0700 |
---|---|---|
committer | Azul <azul@leap.se> | 2013-07-17 10:47:13 +0200 |
commit | 7eab7e33730e12eeb460d2b3965a8712320aff54 (patch) | |
tree | 56ac203fb7f359e8374a9433a5763f4f5e3e4368 /billing/test/unit | |
parent | 5442da999c8398b1e84162996f1e944c6496b095 (diff) |
Very rough start to tests, which still doesn't really use FakeBraintree.
Diffstat (limited to 'billing/test/unit')
-rw-r--r-- | billing/test/unit/customer_test.rb | 38 |
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 |