Skip to content

Commit

Permalink
Format subscription.next_billing_date appropriately.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabe Berke-Williams committed Nov 18, 2011
1 parent 1811656 commit 0dd6471
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/fake_braintree/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ def response_hash
response_hash["add_ons"] = []
response_hash["discounts"] = []
response_hash["plan_id"] = @subscription_hash["plan_id"]
response_hash["next_billing_date"] = 1.month.from_now
response_hash["next_billing_date"] = braintree_formatted_date(1.month.from_now)
response_hash["payment_method_token"] = @subscription_hash["payment_method_token"]
response_hash["status"] = Braintree::Subscription::Status::Active

response_hash
end

private

def braintree_formatted_date(date)
date.strftime('%Y-%m-%d')
end
end
end
4 changes: 2 additions & 2 deletions spec/fake_braintree/subscription_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
first_result.subscription.id.should_not == second_result.subscription.id
end

it "sets the next billing date to 1 month from now in UTC" do
it "sets the next billing date to a string of 1.month.from_now in UTC" do
Timecop.freeze do
result = Braintree::Subscription.create(:payment_method_token => cc_token,
:plan_id => plan_id)

result.subscription.next_billing_date.to_i.should == 1.month.from_now.utc.to_i
result.subscription.next_billing_date.should == 1.month.from_now.utc.strftime('%Y-%m-%d')
end
end

Expand Down

0 comments on commit 0dd6471

Please sign in to comment.