Sha256: 330036aa5df35d0691a4a4ff28bff52bb8e6087ae3fcb1a12a9d41aa57021b17

Contents?: true

Size: 1.56 KB

Versions: 22

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'

describe Spree::ReturnItem::EligibilityValidator::NoReimbursements do
  let(:validator) { Spree::ReturnItem::EligibilityValidator::NoReimbursements.new(return_item) }

  describe "#eligible_for_return?" do

    subject { validator.eligible_for_return? }

    context "inventory unit has already been reimbursed" do
      let(:reimbursement) { create(:reimbursement) }
      let(:return_item)   { reimbursement.return_items.last }

      it "returns false" do
        expect(subject).to eq false
      end

      it "sets an error" do
        subject
        expect(validator.errors[:inventory_unit_reimbursed]).to eq Spree.t('return_item_inventory_unit_reimbursed')
      end
    end

    context "inventory unit has not been reimbursed" do
      let(:return_item) { create(:return_item) }

      it "returns true" do
        expect(subject).to eq true
      end
    end
  end

  describe "#requires_manual_intervention?" do
    subject { validator.requires_manual_intervention? }

    context "not eligible for return" do
      let(:reimbursement) { create(:reimbursement) }
      let(:return_item)   { reimbursement.return_items.last }

      before do
        validator.eligible_for_return?
      end

      it 'returns true if errors were added' do
        expect(subject).to eq true
      end
    end

    context "eligible for return" do
      let(:return_item) { create(:return_item) }

      before do
        validator.eligible_for_return?
      end

      it 'returns false if no errors were added' do
        expect(subject).to eq false
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
spree_core-3.3.0.rc1 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.1.5 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.2.1 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.2.0 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.1.4 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.2.0.rc3 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.2.0.rc2 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.2.0.rc1 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.1.3 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.1.2 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.0.10 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.1.1 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.1.0 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.1.0.rc4 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.0.9 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.1.0.rc3 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.1.0.rc2 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.1.0.rc1 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.0.8 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
spree_core-3.0.7 spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb