Sha256: 26af0bfc63fb60d3c17de598a724ff29033ec3cf71ea11f20a52a2caa3408fb8

Contents?: true

Size: 1.49 KB

Versions: 7

Compression:

Stored size: 1.49 KB

Contents

require_relative '../../test_helper'

module PagarMe
  class BalanceTest < PagarMeTestCase

    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

7 entries across 7 versions & 1 rubygems

Version Path
pagarme-2.3.0 test/pagarme/resources/balance_test.rb
pagarme-2.2.3 test/pagarme/resources/balance_test.rb
pagarme-2.2.2 test/pagarme/resources/balance_test.rb
pagarme-2.2.1 test/pagarme/resources/balance_test.rb
pagarme-2.2.0 test/pagarme/resources/balance_test.rb
pagarme-2.1.4 test/pagarme/resources/balance_test.rb
pagarme-2.1.3 test/pagarme/resources/balance_test.rb