Skip to content

Instantly share code, notes, and snippets.

@litch
Created May 28, 2013 19:44
Show Gist options
  • Save litch/5665523 to your computer and use it in GitHub Desktop.
Save litch/5665523 to your computer and use it in GitHub Desktop.
crazy epic unit test
require 'test_helper'
class MerchantAccountTest < ActiveSupport::TestCase
setup do
@merchant_account = FactoryGirl.create(:merchant_account)
end
should "fetch authorized orders" do
@order = FactoryGirl.create(:order, venue: @merchant_account.venue)
credit_card_hash = {
encrypted: false,
number: "4111111111111111",
name: "Tester Man",
expiration_month: "01",
expiration_year: "16"
}
@transaction = Transaction.new({
user: nil,
payments: [{
amount: @order.total,
credit_card: credit_card_hash,
payment_type: "credit_card"
}],
order: @order,
credit_card_processor: "ipcommerce"
})
@order.update_attribute("state", "delayed")
@order.payments.delete_all
payment = IpcommercePayment.new
payment.state = "authorized"
payment.amount = @order.total
payment.merchant_account = @merchant_account
@order.payments << payment
@order.payments.first.save
#@transaction.close!
assert_equal [payment], @merchant_account.current_payments
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment