Skip to content

Commit

Permalink
I did it, its done, no more failing
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewfl authored and steveklabnik committed Jan 23, 2014
1 parent 5a1a65f commit bf659a8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
37 changes: 20 additions & 17 deletions features/orders.feature
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Feature: Orders

Scenario: Checking escrow of order after creating a credit
Given I have an order with a debit
And I have tokenized a bank account
And I have tokenized a bank account and associated with the merchant
And I POST to /bank_accounts/:bank_account_id/credits with the JSON API body:
"""
{
Expand All @@ -129,7 +129,7 @@ Feature: Orders

Scenario: Orders cannot be credited more than escrow balance
Given I have created an order
And I have tokenized a bank account
And I have tokenized a bank account and associated with the merchant
And I have tokenized a customer card
And I make a POST request to the link "cards.debits" with the body:
"""
Expand Down Expand Up @@ -179,27 +179,30 @@ Feature: Orders
}
"""

@failing @focus
Scenario: Create a reversal
Given I have created an order
And I have tokenized a customer card
And I make a POST request to /customers/:customer_id/orders with the body:
Given I have an order with a debit
And I make a POST request to /customers/:merchant_id/bank_accounts with the body:
"""
{
"order": ":order_id",
"amount": 1234
}
{
"name": "Michael Jordan",
"account_number": "9900000002",
"routing_number": "021000021",
"account_type": "checking"
}
"""
# this bank account does not automatically succeed, which means that the
# credits can not be reversed instantly
# this is how it would normally happen in a prod marketplace
# but there are some ba numbers that can be reversed
And I have tokenized a bank account
And I make a POST request to the link "bank_accounts.credits" with the body:
"""
{
"order": ":order_id",
"amount": 1234
"amount": 12345
}
"""
When I make a GET request to /orders/:order_id
And the response is valid according to the "orders" schema
And the fields on this order match:
"""
{
"amount_escrowed": 0
}
"""

Expand All @@ -213,7 +216,7 @@ Feature: Orders
And the fields on this order match:
"""
{
"amount_escrowed": 0
"amount_escrowed": 12345
}
"""

Expand Down
3 changes: 2 additions & 1 deletion features/step_definitions/orders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

Given(/^I have an order with a debit$/) do
step 'I have created a customer'
merchant = @client.post('/customers', {})
@client.post('/customers', {})
@merchant_id = @client['id']
@client.add_hydrate :merchant_id, @client['id']
@client.post("/customers/#{@client['id']}/orders", {})
@order_id = @client['id']
Expand Down
2 changes: 1 addition & 1 deletion lib/balanced/tiny_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def get_link(keys)
key = body['links'][keys]
kk = key.gsub(/\{(\w+)\.(\w+)\}/) do |match|
a = match[1...-1].split('.')
body[a[0]][0][a[1]]
body[a[0]][0][a[1]] or body[a[0]][0]['links'][a[1]]
end
#require 'debugger'; debugger
return kk
Expand Down

0 comments on commit bf659a8

Please sign in to comment.