From 1c40963194aa6f1dc985b949fb3c05e70f7530c0 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 1 Jul 2013 13:13:02 +0200 Subject: use fake_braintree, fix and test customer with braintree info --- billing/test/unit/customer_test.rb | 6 ----- .../test/unit/customer_with_payment_info_test.rb | 27 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 billing/test/unit/customer_with_payment_info_test.rb (limited to 'billing/test/unit') 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 -- cgit v1.2.3