Sha256: ab00862ee5e4574578807c403a1c1d48ccef266fdecd559d8673ef96b2c939b2

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

require 'spec_helper'

RSpec.describe RockRMS::Response::RecurringDonation, type: :model do
  let(:parsed) { JSON.parse(FixturesHelper.read('recurring_donations.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 'has the following keys' do
      response = result.first
      expected_keys = %i[
        active
        financial_gateway_id
        foreign_key
        frequency
        end_date
        gateway_schedule_id
        next_payment_date
        payment_details
        person_id
        start_date
        transaction_details
        transaction_code
        transaction_type_id
        summary
        id
        created_date_time
        modified_date_time
        attributes
        attribute_values
      ]

      expect(response.keys).to eq(expected_keys)
    end

    it 'translates keys' do
      result.zip(parsed) do |r, p|
        expect(r[:id]).to eq(p['Id'])
        expect(r[:active]).to eq(p['IsActive'])
        expect(r[:financial_gateway_id]).to eq(p['FinancialGatewayId'])
        expect(r[:gateway_schedule_id]).to eq(p['GatewayScheduleId'])
        expect(r[:foreign_key]).to eq(p['ForeignKey'])
        expect(r[:frequency]).to eq('monthly')
        expect(r[:next_payment_date]).to eq(p['NextPaymentDate'])
        expect(r[:person_id]).to eq(p['AuthorizedPersonAliasId'])
        expect(r[:transaction_details]).to eq(
          RockRMS::Response::RecurringDonationDetails.format(p['ScheduledTransactionDetails'])
        )
        expect(r[:transaction_code]).to eq(p['TransactionCode'])
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rock_rms-8.1.0 spec/rock_rms/response/recurring_donation_spec.rb
rock_rms-8.0.0 spec/rock_rms/response/recurring_donation_spec.rb