Sha256: 7aea55918065517b25c7cc8119ad6284e78c1acf784ec5fe26f7ada6607d8f7e

Contents?: true

Size: 941 Bytes

Versions: 48

Compression:

Stored size: 941 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

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

    it 'is deprecated' do
      expect(Spree::Deprecation).to(receive(:warn))
      Spree::Core::CurrentStore.new(double)
    end
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

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