Skip to content

Commit

Permalink
Return the payment method token like Braintree does, so customers/sub…
Browse files Browse the repository at this point in the history
…scriptions can be cross-referenced
  • Loading branch information
jferris committed Nov 15, 2011
1 parent 36f2b5e commit 707b336
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/fake_braintree/subscription.rb
Expand Up @@ -8,12 +8,13 @@ def initialize(request)


def response_hash def response_hash
response_hash = {} response_hash = {}
response_hash["id"] = md5("#{@subscription_hash["payment_method_token"]}#{Time.now.to_f}")[0,6] response_hash["id"] = md5("#{@subscription_hash["payment_method_token"]}#{Time.now.to_f}")[0,6]
response_hash["transactions"] = [] response_hash["transactions"] = []
response_hash["add_ons"] = [] response_hash["add_ons"] = []
response_hash["discounts"] = [] response_hash["discounts"] = []
response_hash["next_billing_date"] = 1.month.from_now response_hash["next_billing_date"] = 1.month.from_now
response_hash["status"] = Braintree::Subscription::Status::Active response_hash["payment_method_token"] = @subscription_hash["payment_method_token"]
response_hash["status"] = Braintree::Subscription::Status::Active


response_hash response_hash
end end
Expand Down
5 changes: 5 additions & 0 deletions spec/fake_braintree/subscription_spec.rb
Expand Up @@ -54,5 +54,10 @@
it "raises a Braintree:NotFoundError when it cannot find a subscription" do it "raises a Braintree:NotFoundError when it cannot find a subscription" do
expect { Braintree::Subscription.find('abc123') }.to raise_error(Braintree::NotFoundError, /abc123/) expect { Braintree::Subscription.find('abc123') }.to raise_error(Braintree::NotFoundError, /abc123/)
end end

it "can find the associated customer" do
subscription = Braintree::Subscription.find(subscription_result.subscription.id)
subscription.payment_method_token.should == payment_method_token
end
end end
end end

0 comments on commit 707b336

Please sign in to comment.