Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't allow customers to be updated with failing credit cards.

  • Loading branch information...
commit a2ceb5805bbb8f87133f0d3475713cd133d54f86 1 parent 783719c
@gabebw gabebw authored
View
10 lib/fake_braintree/customer.rb
@@ -24,9 +24,13 @@ def create
def update
if customer_exists_in_registry?
- updates = customer_hash
- updated_customer = update_existing_customer(updates)
- response_for_updated_customer(updated_customer)
+ if credit_card_is_failure?
+ response_for_invalid_card
+ else
+ updates = customer_hash
+ updated_customer = update_existing_customer(updates)
+ response_for_updated_customer(updated_customer)
+ end
else
response_for_customer_not_found
end
View
9 spec/fake_braintree/customer_spec.rb
@@ -109,6 +109,15 @@
it "raises an error for a nonexistent customer" do
lambda { Braintree::Customer.update("foo", {:first_name => "Bob"}) }.should raise_error(Braintree::NotFoundError)
end
+
+ it "does not allow a customer to be updated to a failing credit card" do
+ bad_credit_card = "123456"
+ FakeBraintree.registry.failures[bad_credit_card] = FakeBraintree.failure_response
+
+ customer = create_customer
+ result = Braintree::Customer.update(customer.customer.id, {:credit_card => { :number => bad_credit_card }})
+ result.should_not be_success
+ end
end
describe "Braintree::Customer.delete" do
Please sign in to comment.
Something went wrong with that request. Please try again.