Sha256: 51021e0610e09d08882a2af203402574eb4f8f54f00d90c21c1aeb1155330d4c

Contents?: true

Size: 880 Bytes

Versions: 48

Compression:

Stored size: 880 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Spree::ReturnItem::EligibilityValidator::RMARequired, type: :model do
  let(:return_item) { create(:return_item) }
  let(:validator) { Spree::ReturnItem::EligibilityValidator::RMARequired.new(return_item) }

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

    context "there is an rma on the return item" do
      it "returns true" do
        expect(subject).to be true
      end
    end

    context "there is no rma on the return item" do
      before { allow(return_item).to receive(:return_authorization).and_return(nil) }

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

      it "sets an error" do
        subject
        expect(validator.errors[:rma_required]).to eq I18n.t('spree.return_item_rma_ineligible')
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
solidus_core-2.10.5 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.10.3 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.10.2 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.9.6 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.8.6 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.10.1 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.9.5 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.10.0 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.9.4 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.6.6 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.7.4 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.8.5 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.9.3 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.9.2 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.10.0.beta1 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.7.3 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.6.5 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.9.1 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.9.0 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
solidus_core-2.9.0.rc.1 spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb