summaryrefslogtreecommitdiff
path: root/engines/billing/test/unit/customer_with_payment_info_test.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-05-16 08:42:36 +0200
committerAzul <azul@leap.se>2014-05-16 08:42:36 +0200
commit8fbbb8717f0578536b97c2dc0883c632f120e976 (patch)
tree17aeb2b48ada703ac916a9a65fbf3c75a5dadb86 /engines/billing/test/unit/customer_with_payment_info_test.rb
parent81555ec6244ed76f92e3629880f68104b8705817 (diff)
parenta4f7a410c536d88c91c834cab6ee950c71005ddd (diff)
Merge remote-tracking branch 'origin/develop'
Conflicts: app/assets/javascripts/srp test/nagios/soledad_sync.py test/nagios/webapp_login.py
Diffstat (limited to 'engines/billing/test/unit/customer_with_payment_info_test.rb')
-rw-r--r--engines/billing/test/unit/customer_with_payment_info_test.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/engines/billing/test/unit/customer_with_payment_info_test.rb b/engines/billing/test/unit/customer_with_payment_info_test.rb
new file mode 100644
index 0000000..0589a59
--- /dev/null
+++ b/engines/billing/test/unit/customer_with_payment_info_test.rb
@@ -0,0 +1,40 @@
+require 'test_helper'
+require 'fake_braintree'
+
+class CustomerWithPaymentInfoTest < ActiveSupport::TestCase
+ include StubRecordHelper
+
+ setup do
+ @user = find_record :user
+ @customer = FactoryGirl.build(:customer_with_payment_info, user: @user)
+ 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 "can access braintree_customer after reload" do
+ @customer.save
+ @customer = Customer.find_by_user_id(@customer.user_id)
+ @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
+ @customer.destroy
+ end
+
+ test "sets default_credit_card" do
+ @customer.with_braintree_data!
+ assert_equal @customer.credit_cards.first, @customer.default_credit_card
+ end
+end