summaryrefslogtreecommitdiff
path: root/billing/test/unit/customer_test.rb
blob: 6156f87a6c274cbb59d4d0f0db50784473655155 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'test_helper'

class CustomerTest < ActiveSupport::TestCase
  include StubRecordHelper

  setup do
    @user = find_record :user
    @customer = FactoryGirl.build(:customer, user: @user)
  end

  test "test set of attributes should be valid" do
    @customer.valid?
    assert_equal Hash.new, @customer.errors.messages
  end

  test "customer belongs to user" do
    assert_equal User, @customer.user.class
  end

  test "user validation" do
    @customer.user = nil
    assert !@customer.valid?
  end

  test "has no payment info" do
    assert !@customer.braintree_customer_id
    assert !@customer.has_payment_info?
  end

  test "with no braintree data" do
    assert_equal @customer, @customer.with_braintree_data!
  end

  test "without default credit card" do
    assert_nil @customer.default_credit_card
  end

end