Sha256: 8223048a97926ff98a7870b162106c8267434b1e3f1788eaad65f25045a9ceb7

Contents?: true

Size: 1.35 KB

Versions: 11

Compression:

Stored size: 1.35 KB

Contents

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

11 entries across 11 versions & 1 rubygems

Version Path
solidus_core-2.5.2 spec/models/spree/store_selector/legacy_spec.rb
solidus_core-2.5.1 spec/models/spree/store_selector/legacy_spec.rb
solidus_core-2.5.0 spec/models/spree/store_selector/legacy_spec.rb
solidus_core-2.5.0.rc1 spec/models/spree/store_selector/legacy_spec.rb
solidus_core-2.5.0.beta2 spec/models/spree/store_selector/legacy_spec.rb
solidus_core-2.5.0.beta1 spec/models/spree/store_selector/legacy_spec.rb
solidus_core-2.4.2 spec/models/spree/store_selector/legacy_spec.rb
solidus_core-2.4.1 spec/models/spree/store_selector/legacy_spec.rb
solidus_core-2.4.0 spec/models/spree/store_selector/legacy_spec.rb
solidus_core-2.4.0.rc1 spec/models/spree/store_selector/legacy_spec.rb
solidus_core-2.4.0.beta1 spec/models/spree/store_selector/legacy_spec.rb