From 7eab7e33730e12eeb460d2b3965a8712320aff54 Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 30 Apr 2013 14:12:08 -0700 Subject: Very rough start to tests, which still doesn't really use FakeBraintree. --- billing/test/unit/customer_test.rb | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 billing/test/unit/customer_test.rb (limited to 'billing/test/unit/customer_test.rb') 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 -- cgit v1.2.3