Permalink
Browse files

Allow Braintree::CreditCard.create without customer

This is valid, according to the docs.
  • Loading branch information...
1 parent c444277 commit b3b439a97c49b56ac729291501c03e0d81450fda @wonnage wonnage committed with gabebw Nov 28, 2012
Showing with 8 additions and 8 deletions.
  1. +5 −5 lib/fake_braintree/credit_card.rb
  2. +3 −3 spec/fake_braintree/credit_card_spec.rb
@@ -8,15 +8,15 @@ def initialize(credit_card_hash_from_params, options)
end
def create
- customer = FakeBraintree.registry.customers[@hash['customer_id']]
- if valid_number? && customer
+ if valid_number?
if token.nil?
@hash['token'] = generate_token
end
FakeBraintree.registry.credit_cards[token] = @hash
- customer['credit_cards'] << @hash
-
- update_default_card
+ if customer = FakeBraintree.registry.customers[@hash['customer_id']]
+ customer['credit_cards'] << @hash
+ update_default_card
+ end
response_for_updated_card
else
response_for_invalid_card
@@ -53,10 +53,10 @@ def build_credit_card_hash
}
end
- it 'fails to create a credit card without a customer' do
+ it 'allows creating a credit card without a customer' do
result = Braintree::CreditCard.create(build_credit_card_hash)
- result.should_not be_success
- expect { Braintree::CreditCard.find('token') }.to raise_exception Braintree::NotFoundError
+ result.should be_success
+ Braintree::CreditCard.find('token').should_not be_nil
end
context 'with a customer' do

0 comments on commit b3b439a

Please sign in to comment.