Skip to content

Commit

Permalink
Require the store_key arg of Store.current
Browse files Browse the repository at this point in the history
The previous behaviour was deprecated
  • Loading branch information
jhawthorn committed Dec 21, 2016
1 parent 64757eb commit 0abb4d0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
3 changes: 1 addition & 2 deletions core/app/models/spree/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class Store < Spree::Base

scope :by_url, lambda { |url| where("url like ?", "%#{url}%") }

def self.current(store_key = nil)
Spree::Deprecation.warn "Spree::Store.current needs a code or URL as an argument. If you want the default store use Spree::Store.default", caller if !store_key
def self.current(store_key)
current_store = Store.find_by(code: store_key) || Store.by_url(store_key).first if store_key
current_store || Store.default
end
Expand Down
8 changes: 0 additions & 8 deletions core/spec/models/spree/store_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@

delegate :current, to: :described_class

context "with no argument" do
it 'should return default' do
Spree::Deprecation.silence do
expect(current).to eql(store_default)
end
end
end

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

0 comments on commit 0abb4d0

Please sign in to comment.