Skip to content

Commit

Permalink
Save add_on amount when adding to Subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
southgate committed Jan 22, 2015
1 parent 698b79e commit 492253b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/fake_braintree/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def braintree_formatted_date(date)

def added_add_ons
if @subscription_hash['add_ons'].is_a?(Hash) && @subscription_hash['add_ons']['add']
@subscription_hash['add_ons']['add'].map { |add_on| { 'id' => add_on['inherited_from_id'] } }
@subscription_hash['add_ons']['add'].map { |add_on| { 'id' => add_on['inherited_from_id'], 'amount' => add_on['amount'] } }
else
[]
end
Expand Down
4 changes: 3 additions & 1 deletion spec/fake_braintree/subscription_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@

it 'returns add-ons added with the subscription' do
add_on_id = 'def456'
subscription_id = create_subscription(add_ons: { add: [{ inherited_from_id: add_on_id }] }).subscription.id
amount = BigDecimal.new('20.00')
subscription_id = create_subscription(add_ons: { add: [{ inherited_from_id: add_on_id, amount: amount }] }).subscription.id
subscription = Braintree::Subscription.find(subscription_id)
add_ons = subscription.add_ons
expect(add_ons.size).to eq 1
expect(add_ons.first.id).to eq add_on_id
expect(add_ons.first.amount).to eq amount
end

it 'returns discounts added with the subscription' do
Expand Down

0 comments on commit 492253b

Please sign in to comment.