Sha256: 606bf18c6b4ebca570b7f07a98bdd48ac3ed4cd9fd6049dd474c360cd75d94f0

Contents?: true

Size: 1.38 KB

Versions: 48

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Spree::StoreSelector::Legacy do
  describe "#store" do
    subject { described_class.new(request).store }

    context "with a default" do
      let(:request) { double(headers: {}, env: {}) }
      let!(:store_1) { create :store, default: true }

      it "returns the default store" do
        expect(subject).to eq(store_1)
      end

      context "with a domain match" do
        let(:request) { double(headers: {}, env: { "SERVER_NAME" => url } ) }
        let(:url) { "server-name.org" }
        let!(:store_2) { create :store, default: false, url: url }

        it "returns the store with the matching domain" do
          expect(subject).to eq(store_2)
        end

        context 'the store has multiple URLs' do
          let!(:store_2) { create :store, default: false, url: "foo\n#{url}\nbar" }

          it "returns the store with the matching domain" do
            expect(subject).to eq(store_2)
          end
        end

        context "with headers" do
          let(:request) { double(headers: { "HTTP_SPREE_STORE" => headers_code }, env: {}) }
          let(:headers_code) { "HEADERS" }
          let!(:store_3) { create :store, code: headers_code, default: false }

          it "returns the store with the matching code" do
            expect(subject).to eq(store_3)
          end
        end
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

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