Sha256: 75211516bf8facc2f2d905fbc6fdb18546b5a9254d3215dbcf86ab38d8bfe311

Contents?: true

Size: 1.17 KB

Versions: 37

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

RSpec.describe RockRMS::Response::Transaction, type: :model do
  let(:parsed) { JSON.parse(FixturesHelper.read('transactions.json')) }

  describe '.format' do
    subject(:result) { described_class.format(parsed) }

    context 'when response is array' do
      it 'returns an array' do
        expect(described_class.format([])).to be_a(Array)
      end
    end

    it 'translates keys' do
      result.take(1).zip(parsed) do |r, p|
        expect(r[:id]).to eq(p['Id'])
        expect(r[:date]).to eq(p['TransactionDateTime'])
        expect(r[:batch_id]).to eq(p['BatchId'])
        expect(r[:recurring_donation_id]).to eq(p['ScheduledTransactionId'])
        expect(r[:summary]).to eq(p['Summary'])
        expect(r[:transaction_code]).to eq(p['TransactionCode'])
        expect(r[:payment_detail_id]).to eq(p['FinancialPaymentDetailId'])
        expect(r[:transaction_type_id]).to eq(p['TransactionTypeValueId'])
        expect(r[:source_type_id]).to eq(p['SourceTypeValueId'])
        expect(r[:details]).to eq(
          RockRMS::Response::TransactionDetail.format(p['TransactionDetails'])
        )
        expect(r[:amount]).to eq(100.00)
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
rock_rms-9.13.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-9.12.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-9.11.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-9.10.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-9.9.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-9.8.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-9.7.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-9.6.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-9.5.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-9.4.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-9.3.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-9.2.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-9.1.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-9.0.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-8.23.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-8.22.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-8.21.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-8.20.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-8.19.0 spec/rock_rms/response/transaction_spec.rb
rock_rms-8.18.0 spec/rock_rms/response/transaction_spec.rb