Skip to content

Commit

Permalink
Merge pull request #5224 from solidusio/elia/current-store-default-do…
Browse files Browse the repository at this point in the history
…main

Ensure the fallback `current_store` has a domain set
  • Loading branch information
elia authored Jul 6, 2023
2 parents 5f9c960 + 33fbd43 commit afa4d89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/app/models/spree/store_selector/by_server_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def store
store = Spree::Store.where(url: server_name).or(Store.where(default: true)).order(default: :asc).first

# Provide a fallback, mostly for legacy/testing purposes
store || Spree::Store.new
store || Spree::Store.new(url: server_name)
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions core/spec/models/spree/store_selector/by_server_name_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
RSpec.describe Spree::StoreSelector::ByServerName do
describe "#store" do
subject { described_class.new(request).store }
let(:request) { double(headers: {}, env: { "SERVER_NAME" => "www.example.com" } ) }

context "with no match" do
it "returns a new store with current domain as the url" do
expect(subject).to be_a_new(Spree::Store).with(url: "www.example.com")
end
end

context "with a default" do
let(:request) { double(headers: {}, env: {}) }
Expand Down

0 comments on commit afa4d89

Please sign in to comment.