Sha256: 4c4aeda4f0522844b15f7221daddb5e1af3f4e99ecae65af2aa097ce7e1a9663

Contents?: true

Size: 1.14 KB

Versions: 32

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

module Spree
  describe Reimbursement::Credit, type: :model do
    context 'class methods' do
      describe '.total_amount_reimbursed_for' do
        subject { Spree::Reimbursement::Credit.total_amount_reimbursed_for(reimbursement) }

        let(:reimbursement) { create(:reimbursement) }
        let(:credit_double) { double(amount: 99.99) }

        before { allow(reimbursement).to receive(:credits).and_return([credit_double, credit_double]) }

        it 'should sum the amounts of all of the reimbursements credits' do
          expect(subject).to eq BigDecimal.new('199.98')
        end
      end
    end

    describe '#description' do
      let(:credit) { Spree::Reimbursement::Credit.new(amount: 100, creditable: mock_model(Spree::PaymentMethod::Check)) }

      it "should be the creditable's class name" do
        expect(credit.description).to eq 'Check'
      end
    end

    describe '#display_amount' do
      let(:credit) { Spree::Reimbursement::Credit.new(amount: 100) }

      it 'should be a money object' do
        expect(credit.display_amount).to eq Spree::Money.new(100, currency: "USD")
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
solidus_core-2.3.1 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.2.2 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.1.1 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.0.3 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-1.4.2 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-1.3.2 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.3.0 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.3.0.rc3 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.3.0.rc2 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.3.0.rc1 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.3.0.beta1 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.0.2 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-1.4.1 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.2.1 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.2.0 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.2.0.rc1 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.2.0.beta1 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.1.0 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.1.0.rc1 spec/models/spree/reimbursement/credit_spec.rb
solidus_core-2.0.1 spec/models/spree/reimbursement/credit_spec.rb