summaryrefslogtreecommitdiff
path: root/billing/test/unit
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-07-01 13:13:02 +0200
committerAzul <azul@leap.se>2013-07-17 10:47:14 +0200
commit1c40963194aa6f1dc985b949fb3c05e70f7530c0 (patch)
treed03cb2b420f0b8d5dfec2f0b2c875d157782c275 /billing/test/unit
parenta49c63eb117abf47ca1804493c25ae34804f8ee1 (diff)
use fake_braintree, fix and test customer with braintree info
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