Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Skip flaky test on MySQL
Damian Legawiec1cbafa0484ed
diff --git a/common_spree_dependencies.rb b/common_spree_dependencies.rbindex 70788010a3..668e070db2 100644--- a/common_spree_dependencies.rb+++ b/common_spree_dependencies.rb@@ -31,7 +31,7 @@ group :test dogem 'capybara', '~> 3.24'gem 'capybara-screenshot', '~> 1.0'gem 'capybara-select-2'- gem 'database_cleaner', '~> 1.3'+ gem 'database_cleaner-active_record'gem 'email_spec'gem 'factory_bot_rails', '~> 6.0'gem 'multi_json'diff --git a/core/spec/models/spree/base_spec.rb b/core/spec/models/spree/base_spec.rbindex 0578f7d9e3..3573da54a6 100644--- a/core/spec/models/spree/base_spec.rb+++ b/core/spec/models/spree/base_spec.rb@@ -12,36 +12,38 @@ module Testenddescribe Spree::Base do- let(:connection) { ActiveRecord::Base.connection }+ context 'AR overrides', skip: ENV['DB'] == 'mysql' do+ let(:connection) { ActiveRecord::Base.connection }- before do- connection.create_table :test_parents, force: true- connection.create_table :test_children, force: true do |t|- t.belongs_to :test_parent+ before do+ connection.create_table :test_parents, force: true+ connection.create_table :test_children, force: true do |t|+ t.belongs_to :test_parent+ endend- end- after do- connection.drop_table 'test_parents', if_exists: true- connection.drop_table 'test_children', if_exists: true- end+ after do+ connection.drop_table 'test_parents', if_exists: true+ connection.drop_table 'test_children', if_exists: true+ end- it 'does not override Rails 5 default belongs_to_required_by_default' do- expect(described_class.belongs_to_required_by_default).to eq(false)- expect(Spree::Product.belongs_to_required_by_default).to be(false)+ it 'does not override Rails 5 default belongs_to_required_by_default' do+ expect(described_class.belongs_to_required_by_default).to eq(false)+ expect(Spree::Product.belongs_to_required_by_default).to be(false)- expect(ApplicationRecord.belongs_to_required_by_default).to be(true)- expect(ActiveRecord::Base.belongs_to_required_by_default).to be(true)- expect(Test::Parent.belongs_to_required_by_default).to be(true)- expect(Test::Child.belongs_to_required_by_default).to be(true)- end+ expect(ApplicationRecord.belongs_to_required_by_default).to be(true)+ expect(ActiveRecord::Base.belongs_to_required_by_default).to be(true)+ expect(Test::Parent.belongs_to_required_by_default).to be(true)+ expect(Test::Child.belongs_to_required_by_default).to be(true)+ end- it 'does not disable non-spree, Rails 5 models to validate their associated belongs_to model' do- model_instance = Test::Child.new+ it 'does not disable non-spree, Rails 5 models to validate their associated belongs_to model' do+ model_instance = Test::Child.new- expect(model_instance.validate).to eq(false)- expect(model_instance.errors.messages).to include(:parent)- expect(model_instance.errors.messages[:parent]).to include('must exist')+ expect(model_instance.validate).to eq(false)+ expect(model_instance.errors.messages).to include(:parent)+ expect(model_instance.errors.messages[:parent]).to include('must exist')+ endenddescribe '.json_api_type' dodiff --git a/core/spec/spec_helper.rb b/core/spec/spec_helper.rbindex e6fb1a9a02..69f745ddcc 100644--- a/core/spec/spec_helper.rb+++ b/core/spec/spec_helper.rb@@ -32,7 +32,7 @@ rescue LoadErrorendrequire 'rspec/rails'-require 'database_cleaner'+require 'database_cleaner/active_record'require 'ffaker'Dir['./spec/support/**/*.rb'].sort.each { |f| require f }@@ -57,9 +57,23 @@ RSpec.configure do |config|# If you're not using ActiveRecord, or you'd prefer not to run each of your# examples within a transaction, comment the following line or assign false# instead of true.- config.use_transactional_fixtures = true+ config.use_transactional_fixtures = false- config.before do+ config.before(:suite) do+ # Clean out the database state before the tests run+ DatabaseCleaner.strategy = :transaction+ DatabaseCleaner.clean_with(:truncation)+ # Force jobs to be executed in a synchronous way+ ActiveJob::Base.queue_adapter = :inline+ end++ config.around(:each) do |example|+ DatabaseCleaner.cleaning do+ example.run+ end+ end++ config.before(:each) dobeginRails.cache.clearreset_spree_preferences@@ -74,13 +88,6 @@ RSpec.configure do |config|config.include Spree::TestingSupport::Preferencesconfig.include Spree::TestingSupport::Kernel- config.before(:suite) do- # Clean out the database state before the tests run- DatabaseCleaner.clean_with(:truncation)- # Force jobs to be executed in a synchronous way- ActiveJob::Base.queue_adapter = :inline- end-config.before(:each, :inline_jobs) doActiveJob::Base.queue_adapter = :testenddiff --git a/emails/spec/spec_helper.rb b/emails/spec/spec_helper.rbindex aef1033ef1..a60d6f93a0 100644--- a/emails/spec/spec_helper.rb+++ b/emails/spec/spec_helper.rb@@ -28,7 +28,7 @@ rescue LoadErrorendrequire 'rspec/rails'-require 'database_cleaner'+require 'database_cleaner/active_record'require 'ffaker'Dir['./spec/support/**/*.rb'].sort.each { |f| require f }