diff --git a/.ruby-version b/.ruby-version index be94e6f..fa7adc7 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.2.2 +3.3.5 diff --git a/Gemfile b/Gemfile index f1d62f9..42ece09 100644 --- a/Gemfile +++ b/Gemfile @@ -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' @@ -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 diff --git a/app/controllers/controllers_decorator.rb b/app/controllers/controllers_decorator.rb index db65f78..946638c 100644 --- a/app/controllers/controllers_decorator.rb +++ b/app/controllers/controllers_decorator.rb @@ -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 diff --git a/lib/spree_multi_tenant.rb b/lib/spree_multi_tenant.rb index 475c488..01d12b6 100644 --- a/lib/spree_multi_tenant.rb +++ b/lib/spree_multi_tenant.rb @@ -111,6 +111,7 @@ def self.tenanted_models [ 'Spree::CmsPage', 'Spree::CmsSection', + 'Spree::DataFeed', 'Spree::Digital', 'Spree::DigitalLink', 'Spree::Menu', @@ -150,4 +151,3 @@ def self.with_tenant(tenant, &block) end end - diff --git a/spec/controllers/controller_spec.rb b/spec/controllers/controller_spec.rb index c000165..e93f54c 100644 --- a/spec/controllers/controller_spec.rb +++ b/spec/controllers/controller_spec.rb @@ -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 diff --git a/spec/models/preferences_spec.rb b/spec/models/preferences_spec.rb index 28c42bc..d05e665 100644 --- a/spec/models/preferences_spec.rb +++ b/spec/models/preferences_spec.rb @@ -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 diff --git a/spec/requests/requests_spec.rb b/spec/requests/requests_spec.rb index a9defc3..578f7ba 100644 --- a/spec/requests/requests_spec.rb +++ b/spec/requests/requests_spec.rb @@ -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") @@ -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