Sha256: d804bdf517946b024e5d7f1b0159933a22ac933b89d96ddb33ec429e8b6926a4

Contents?: true

Size: 1.94 KB

Versions: 37

Compression:

Stored size: 1.94 KB

Contents

describe MangoPay::Transaction do
  include_context 'wallets'
  include_context 'payins'
  include_context 'payouts'

  describe 'FETCH' do

    it 'fetches empty list of transactions if no transactions done' do
      transactions = MangoPay::Transaction.fetch(new_wallet['Id'])
      expect(transactions).to be_kind_of(Array)
      expect(transactions).to be_empty
    end

    it 'fetches list with single transaction after payin done' do
      payin = new_payin_card_direct
      transactions = MangoPay::Transaction.fetch(new_wallet['Id'])
      expect(transactions).to be_kind_of(Array)
      expect(transactions.count).to eq 1
      expect(transactions.first['Id']).to eq payin['Id']
    end

    it 'fetches list with two transactions after payin and payout done' do
      payin = new_payin_card_direct
      payout = create_new_payout_bankwire(payin)
      transactions = MangoPay::Transaction.fetch(new_wallet['Id'])

      expect(transactions).to be_kind_of(Array)
      expect(transactions.count).to eq 2

      transactions_ids = transactions.map {|t| t['Id']}
      expect(transactions_ids).to include payin['Id']
      expect(transactions_ids).to include payout['Id']
    end

    it 'accepts filtering params' do
      payin = new_payin_card_direct
      payout = create_new_payout_bankwire(payin)
      wallet_id = new_wallet['Id']

      by_nature_reg = MangoPay::Transaction.fetch(wallet_id, {'Nature' => 'REGULAR'})
      by_nature_ref = MangoPay::Transaction.fetch(wallet_id, {'Nature' => 'REFUND'})
      expect(by_nature_reg.count).to eq 2
      expect(by_nature_ref.count).to eq 0

      by_type_pyin  = MangoPay::Transaction.fetch(wallet_id, {'Type' => 'PAYIN'})
      by_type_pyout = MangoPay::Transaction.fetch(wallet_id, {'Type' => 'PAYOUT'})
      expect(by_type_pyin.count).to eq 1
      expect(by_type_pyout.count).to eq 1
      expect(by_type_pyin.first['Id']).to eq payin['Id']
      expect(by_type_pyout.first['Id']).to eq payout['Id']
    end

  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
mangopay-3.21.0 spec/mangopay/transaction_spec.rb
mangopay-3.20.0 spec/mangopay/transaction_spec.rb
mangopay-3.19.0 spec/mangopay/transaction_spec.rb
mangopay-3.18.0 spec/mangopay/transaction_spec.rb
mangopay-3.17.0 spec/mangopay/transaction_spec.rb
mangopay-3.16.0 spec/mangopay/transaction_spec.rb
mangopay-3.15.0 spec/mangopay/transaction_spec.rb
mangopay-3.14.0 spec/mangopay/transaction_spec.rb
mangopay-3.13.2 spec/mangopay/transaction_spec.rb
mangopay-3.12.0 spec/mangopay/transaction_spec.rb
mangopay-3.11.1 spec/mangopay/transaction_spec.rb
mangopay-3.11.0 spec/mangopay/transaction_spec.rb
mangopay-3.10.0 spec/mangopay/transaction_spec.rb
mangopay-3.9.0 spec/mangopay/transaction_spec.rb
mangopay-3.8.0 spec/mangopay/transaction_spec.rb
mangopay-3.7.0 spec/mangopay/transaction_spec.rb
mangopay-3.6.0 spec/mangopay/transaction_spec.rb
mangopay-3.5.0 spec/mangopay/transaction_spec.rb
mangopay-3.4.0 spec/mangopay/transaction_spec.rb
mangopay-3.3.0 spec/mangopay/transaction_spec.rb