Sha256: c358751570fd004d98baff63a813d1b7ce621ff9918083d49ca0ba1cbd5033d3
Contents?: true
Size: 1.64 KB
Versions: 16
Compression:
Stored size: 1.64 KB
Contents
require 'spec_helper' describe Spree::Store, :type => :model do describe ".by_url" do let!(:store) { create(:store, url: "website1.com\nwww.subdomain.com") } let!(:store_2) { create(:store, url: 'freethewhales.com') } it "should find stores by url" do by_domain = Spree::Store.by_url('www.subdomain.com') expect(by_domain).to include(store) expect(by_domain).not_to include(store_2) end end describe '.current' do # there is a default store created with the test_app rake task. let!(:store_1) { Spree::Store.first || create(:store) } let!(:store_2) { create(:store, default: false, url: 'www.subdomain.com') } let!(:store_3) { create(:store, default: false, url: 'www.another.com', code: 'CODE')} it 'should return default when no domain' do expect(subject.class.current).to eql(store_1) end it 'should return store for domain' do expect(subject.class.current('spreecommerce.com')).to eql(store_1) expect(subject.class.current('www.subdomain.com')).to eql(store_2) end it 'should return store by code' do expect(subject.class.current('CODE')).to eql(store_3) end end describe ".default" do let!(:store) { create(:store) } let!(:store_2) { create(:store, default: true) } it "should ensure there is a default if one doesn't exist yet" do expect(store_2.default).to be true end it "should ensure there is only one default" do [store, store_2].each(&:reload) expect(Spree::Store.where(default: true).count).to eq(1) expect(store_2.default).to be true expect(store.default).not_to be true end end end
Version data entries
16 entries across 16 versions & 1 rubygems