Skip to content
This repository
Browse code

Return the payment method token like Braintree does, so customers/sub…

…scriptions can be cross-referenced
  • Loading branch information...
commit 707b336ddc773070d4d1882ca6e0e7a75b643621 1 parent 36f2b5e
Joe Ferris authored November 15, 2011
13  lib/fake_braintree/subscription.rb
@@ -8,12 +8,13 @@ def initialize(request)
8 8
 
9 9
     def response_hash
10 10
       response_hash = {}
11  
-      response_hash["id"]                = md5("#{@subscription_hash["payment_method_token"]}#{Time.now.to_f}")[0,6]
12  
-      response_hash["transactions"]      = []
13  
-      response_hash["add_ons"]           = []
14  
-      response_hash["discounts"]         = []
15  
-      response_hash["next_billing_date"] = 1.month.from_now
16  
-      response_hash["status"]            = Braintree::Subscription::Status::Active
  11
+      response_hash["id"]                   = md5("#{@subscription_hash["payment_method_token"]}#{Time.now.to_f}")[0,6]
  12
+      response_hash["transactions"]         = []
  13
+      response_hash["add_ons"]              = []
  14
+      response_hash["discounts"]            = []
  15
+      response_hash["next_billing_date"]    = 1.month.from_now
  16
+      response_hash["payment_method_token"] = @subscription_hash["payment_method_token"]
  17
+      response_hash["status"]               = Braintree::Subscription::Status::Active
17 18
 
18 19
       response_hash
19 20
     end
5  spec/fake_braintree/subscription_spec.rb
@@ -54,5 +54,10 @@
54 54
     it "raises a Braintree:NotFoundError when it cannot find a subscription" do
55 55
       expect { Braintree::Subscription.find('abc123') }.to raise_error(Braintree::NotFoundError, /abc123/)
56 56
     end
  57
+
  58
+    it "can find the associated customer" do
  59
+      subscription = Braintree::Subscription.find(subscription_result.subscription.id)
  60
+      subscription.payment_method_token.should == payment_method_token
  61
+    end
57 62
   end
58 63
 end

0 notes on commit 707b336

Please sign in to comment.
Something went wrong with that request. Please try again.