Sha256: b059655467f529ababbc418310ed15266b04e7c4b98dc0ad71f32336ed0de89b

Contents?: true

Size: 1.84 KB

Versions: 26

Compression:

Stored size: 1.84 KB

Contents

describe Moneta::Api::Requests::AuthoriseTransactionBatchRequest do
  describe 'Entity extension' do
    subject { described_class.new.properties.keys }

    it { is_expected.to be_include(:version) }
    it { is_expected.to be_include(:transactional) }
  end

  describe '#add_transaction' do
    let(:request) { described_class.new }
    let(:add_transaction) { request.add_transaction(item) }

    context 'when valid item' do
      let(:item) { Moneta::Api::Requests::PaymentRequest.new }

      it 'should success add' do
        add_transaction
        expect(request.transaction.count).to eq 1
      end
    end

    context 'when invalid item' do
      let(:item) { Hash.new }

      it { expect { add_transaction }.to raise_error }
    end
  end

  describe 'use', vcr: true do
    include_context 'moneta'

    let(:data) {
      {
        amount: 10,
        payee: 28988504,
        payer: 10999,
        is_payer_amount: false,
        payment_password: '12345'
      }
    }
    let(:request) do
      described_class.new.tap do |request|
        request.transactional = false
        request.exit_on_failure = true
        operations.each { |o| request.add_transaction(o) }
      end
    end

    subject { service.authorise_transaction_batch(request) }

    context 'when one operation' do
      let(:operations) do
        [
          Moneta::Api::Requests::TransferRequest.build(data)
        ]
      end

      its('transaction.transaction') { is_expected.to be_a_kind_of(Moneta::Api::Types::OperationInfo) }
    end

    context 'when two operations' do
      let(:operations) do
        [
          Moneta::Api::Requests::TransferRequest.build(data),
          Moneta::Api::Requests::TransferRequest.build(data)
        ]
      end

      its('transaction.first.transaction') { is_expected.to be_a_kind_of(Moneta::Api::Types::OperationInfo) }
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
moneta-api-1.13.0 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.12.8 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.12.7 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.12.6 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.12.5 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.12.4 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.12.3 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.12.2 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.12.1 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.12.0 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.11.0 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.10.0 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.9.0 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.8.0 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.7.0 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.6.0 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.5.0 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.4.0 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.3.0 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
moneta-api-1.2.1 spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb