Sha256: 3045b388046b69c7410a222435dc689d6169be1ff1a30ecf94e9741fff7b9797

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

require_relative '../../test_helper'

module PagarMe
  class BalanceTest < Test::Unit::TestCase

    should 'change amount amount after transaction being paid' do
      transaction      = PagarMe::Transaction.charge transaction_with_boleto_params
      previous_balance = PagarMe::Balance.balance

      transaction.status = :paid
      transaction.save

      balance = PagarMe::Balance.balance
      assert_increased_available_amount previous_balance, balance
    end

    should 'change recipient amount after transaction being paid' do
      recipient   = PagarMe::Recipient.create recipient_with_nested_bank_account_params
      split_rules = [ { recipient_id: recipient.id, percentage: 100 } ]
      transaction = PagarMe::Transaction.charge transaction_with_boleto_params(split_rules: split_rules)

      assert_empty_balance recipient.balance

      transaction.status = :paid
      transaction.save

      assert_available_balance recipient.balance
    end

    should 'change recipient amount after recipient receive money' do
      recipient   = PagarMe::Recipient.create recipient_with_nested_bank_account_params
      split_rules = [ { recipient_id: recipient.id, percentage: 100 } ]
      transaction = PagarMe::Transaction.charge transaction_with_boleto_params(split_rules: split_rules)

      assert_empty_balance recipient.balance

      transaction.status = :paid
      transaction.save

      recipient.receive recipient.balance.available.amount

      assert_transfered_balance recipient.balance
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pagarme-2.1.2 test/pagarme/resources/balance_test.rb
pagarme-2.1.1 test/pagarme/resources/balance_test.rb
pagarme-2.1.0 test/pagarme/resources/balance_test.rb