Total Pageviews

5,443,482

Wednesday, 29 January 2025

Blog With Spree

 Reproducible Test Case for https://github.com/spree/spree/issues/8298

Sample app that demonstrates a spree issue: spree/spree#8298 The issue was previously deemed fixed but I'm not sure which tests cover it, since spree/spree#8297 did not have a test.

Local Installation

git clone git@github.com:padi/blog_with_spree.git
cd blog_with_spree
bundle install

Test that demonstrates the bug

DISABLE_SPRING=1 rails test test/models/application_record_test.rb

The temporary fix is created in: app/models/application_record.rb, specifically overriding ApplicationRecord.belongs_to_required_by_default

class ApplicationRecord < ActiveRecord::Base
  self.abstract_class = true
   # Temporary fix by opting out from mattr_accessor :belongs_to_required_by_default
  def self.belongs_to_required_by_default
    true
  end
end

... but that fix would only work for models that inherit from ApplicationRecord, which may not include other models from other engines.

from https://github.com/padi/blog_with_spree

 

No comments:

Post a Comment