Sha256: 38bf81fcf0adf0f00d3d53bf0b82d2028e02897596c8b50a3679406dc00d04df

Contents?: true

Size: 1.62 KB

Versions: 32

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'

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

  describe "#eligible_for_return?" do
    before { allow(return_item.inventory_unit).to receive(:shipped?).and_return(true) }

    subject { validator.eligible_for_return? }

    context "the associated inventory unit is shipped" do
      it "returns true" do
        expect(subject).to eq true
      end
    end

    context "the associated inventory unit is not shipped" do
      before { allow(return_item.inventory_unit).to receive(:shipped?).and_return(false) }

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

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

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

    context "not eligible for return" do
      before do
        allow(return_item.inventory_unit).to receive(:shipped?).and_return(false)
        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
      before do
        allow(return_item.inventory_unit).to receive(:shipped?).and_return(true)
        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

32 entries across 32 versions & 1 rubygems

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