Skip to content

Commit

Permalink
Remove deprecated Spree::Store.current method
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielePalombo authored and kennyadsl committed Jan 28, 2021
1 parent e8a002d commit bae6572
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 38 deletions.
6 changes: 0 additions & 6 deletions core/app/models/spree/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ def available_locales=(locales)
end
end

def self.current(store_key)
Spree::Deprecation.warn "Spree::Store.current is DEPRECATED"
current_store = Store.find_by(code: store_key) || Store.by_url(store_key).first if store_key
current_store || Store.default
end

def self.default
where(default: true).first || new
end
Expand Down
32 changes: 0 additions & 32 deletions core/spec/models/spree/store_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,6 @@
end
end

describe '.current (deprecated)' do
let!(:store_1) { create(:store) }
let!(:store_default) { create(:store, name: 'default', default: true) }
let!(:store_2) { create(:store, default: false, url: 'www.subdomain.com') }
let!(:store_3) { create(:store, default: false, url: 'www.another.com', code: 'CODE') }

before do
expect(Spree::Deprecation).to receive(:warn).
with(/^Spree::Store.current is DEPRECATED/, any_args)
end

delegate :current, to: :described_class

context "with no match" do
it 'should return the default domain' do
expect(current('foobar.com')).to eql(store_default)
end
end

context "with matching url" do
it 'should return matching store' do
expect(current('www.subdomain.com')).to eql(store_2)
end
end

context "with matching code" do
it 'should return matching store' do
expect(current('CODE')).to eql(store_3)
end
end
end

describe ".default" do
it "should ensure saved store becomes default if one doesn't exist yet" do
expect(Spree::Store.where(default: true).count).to eq(0)
Expand Down

0 comments on commit bae6572

Please sign in to comment.