Sha256: 05657a534a421bbf557308ceba80638a58a25a1cb89d08c3438d323be75fdbcb

Contents?: true

Size: 1.09 KB

Versions: 42

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe Spree::Core::CurrentStore do
  describe "#store" do
    subject { Spree::Core::CurrentStore.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 "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

42 entries across 42 versions & 1 rubygems

Version Path
solidus_core-2.2.2 spec/lib/spree/core/current_store_spec.rb
solidus_core-2.1.1 spec/lib/spree/core/current_store_spec.rb
solidus_core-2.0.3 spec/lib/spree/core/current_store_spec.rb
solidus_core-1.4.2 spec/lib/spree/core/current_store_spec.rb
solidus_core-1.3.2 spec/lib/spree/core/current_store_spec.rb
solidus_core-1.2.3 spec/lib/spree/core/current_store_spec.rb
solidus_core-1.1.4 spec/lib/spree/core/current_store_spec.rb
solidus_core-1.0.7 spec/lib/spree/core/current_store_spec.rb
solidus_core-2.0.2 spec/lib/spree/core/current_store_spec.rb
solidus_core-1.4.1 spec/lib/spree/core/current_store_spec.rb
solidus_core-2.2.1 spec/lib/spree/core/current_store_spec.rb
solidus_core-2.2.0 spec/lib/spree/core/current_store_spec.rb
solidus_core-2.2.0.rc1 spec/lib/spree/core/current_store_spec.rb
solidus_core-2.2.0.beta1 spec/lib/spree/core/current_store_spec.rb
solidus_core-2.1.0 spec/lib/spree/core/current_store_spec.rb
solidus_core-2.1.0.rc1 spec/lib/spree/core/current_store_spec.rb
solidus_core-2.0.1 spec/lib/spree/core/current_store_spec.rb
solidus_core-2.1.0.beta1 spec/lib/spree/core/current_store_spec.rb
solidus_core-2.0.0 spec/lib/spree/core/current_store_spec.rb
solidus_core-1.4.0 spec/lib/spree/core/current_store_spec.rb