Skip to content

Commit

Permalink
Upgrade to Spree 4.10
Browse files Browse the repository at this point in the history
  • Loading branch information
earllevine committed Dec 17, 2024
1 parent 225ca69 commit 34c2e38
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.2
3.3.5
15 changes: 8 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end

gem 'spree_core', '4.5.0'
gem 'spree_backend', '4.5.0'
gem 'spree_frontend', '4.5.0'
gem 'spree_emails', '4.5.0'
gem 'spree_core', '4.10.1'
gem 'spree_backend', '4.8.4'
gem 'spree_frontend', '4.8.0'
gem 'spree_emails', '4.10.0'
# Provides basic authentication functionality for testing parts of your engine
gem 'spree_auth_devise', '4.5.0'
gem 'spree_auth_devise', '4.6.3'
gem 'rails-controller-testing'

gem 'sqlite3', '~> 1.4'
Expand All @@ -20,8 +20,9 @@ gem 'rubocop-rspec', require: false

group :test do
gem 'pg'
gem 'redis', '4.4.0'
gem 'email_spec', '2.2.1'
gem 'redis', '5.3.0'
gem 'email_spec', '2.3.0'
gem 'rspec-rails', '~> 7.1'
end

gemspec
1 change: 1 addition & 0 deletions app/controllers/controllers_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def set_without_persist(key, value)

module SpreeMultiTenant
def self.init_preferences
Spree::Api::Config.send(:initialize)
Spree::Preference.all.each do |preference|
Spree::Preferences::Store.instance.set_without_persist(preference.key, preference.value)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/spree_multi_tenant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def self.tenanted_models
[
'Spree::CmsPage',
'Spree::CmsSection',
'Spree::DataFeed',
'Spree::Digital',
'Spree::DigitalLink',
'Spree::Menu',
Expand Down Expand Up @@ -150,4 +151,3 @@ def self.with_tenant(tenant, &block)
end

end

6 changes: 6 additions & 0 deletions spec/controllers/controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
describe "with multiple tenants", type: :controller do
before(:each) do
@tenant1 = FactoryBot.create(:tenant)
Multitenant.with_tenant @tenant1 do
FactoryBot.create(:store, default_country: FactoryBot.create(:country))
end
@tenant2 = FactoryBot.create(:tenant)
Multitenant.with_tenant @tenant2 do
FactoryBot.create(:store, default_country: FactoryBot.create(:country))
end

@request.host = @tenant1.domain
end
Expand Down
11 changes: 4 additions & 7 deletions spec/models/preferences_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,17 @@
before do
@tenant1 = FactoryBot.create(:tenant)
@tenant2 = FactoryBot.create(:tenant)

SpreeMultiTenant.with_tenant @tenant1 do
Spree::Api::Config[:api_v2_per_page_limit] = 1
end
SpreeMultiTenant.with_tenant @tenant2 do
Spree::Api::Config[:api_v2_per_page_limit] = 2
end
end

it "should have the right preference for the tenant" do
SpreeMultiTenant.with_tenant @tenant1 do
Spree::Api::Config.api_v2_per_page_limit.should == 500 # default
Spree::Api::Config[:api_v2_per_page_limit] = 1
Spree::Api::Config.api_v2_per_page_limit.should == 1
end
SpreeMultiTenant.with_tenant @tenant2 do
Spree::Api::Config.api_v2_per_page_limit.should == 500 # default
Spree::Api::Config[:api_v2_per_page_limit] = 2
Spree::Api::Config.api_v2_per_page_limit.should == 2
end
end
Expand Down
26 changes: 12 additions & 14 deletions spec/requests/requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@ def login(user, tenant=user.tenant)
describe "with multiple tenants", type: :request do
before(:each) do
@tenant1 = FactoryBot.create(:tenant)
Multitenant.with_tenant @tenant1 do
FactoryBot.create(:store, default_country: FactoryBot.create(:country))
Spree::Store.default.update(seo_title: 'Site1Title')
end
@tenant2 = FactoryBot.create(:tenant)
Multitenant.with_tenant @tenant2 do
FactoryBot.create(:store, default_country: FactoryBot.create(:country))
Spree::Store.default.update(seo_title: 'Site2Title')
end
end

context "visiting the homepage page" do
before do
Multitenant.with_tenant @tenant1 do
FactoryBot.create(:store)
Spree::Store.default.update(seo_title: 'Site1Title')
end
Multitenant.with_tenant @tenant2 do
FactoryBot.create(:store)
Spree::Store.default.update(seo_title: 'Site2Title')
end
end

it "homepage should display the page title for the tenant" do
visit "http://#{@tenant1.domain}"
page.title.should include("Site1Title")
Expand Down Expand Up @@ -61,9 +58,10 @@ def login(user, tenant=user.tenant)
end

it "#show should not display a different tenant's product" do
expect{
visit "http://#{@tenant1.domain}/products/#{@product2.slug}"
}.to raise_error(ActiveRecord::RecordNotFound)
visit "http://#{@tenant1.domain}/products/#{@product2.slug}"
expect(page.status_code).to eq(404)
page.should_not have_content(@product1.name)
page.should_not have_content(@product2.name)
end
end

Expand Down

0 comments on commit 34c2e38

Please sign in to comment.