Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Added `Taxon#store` method (#12139)

Damian Legawiecd05ca4a90e5e
diff --git a/core/app/models/spree/taxon.rb b/core/app/models/spree/taxon.rb
index 6865f64892..466752a2cb 100644
--- a/core/app/models/spree/taxon.rb
+++ b/core/app/models/spree/taxon.rb
@@ -21,6 +21,8 @@ module Spree
has_many :classifications, -> { order(:position) }, dependent: :delete_all, inverse_of: :taxon
has_many :products, through: :classifications
+ delegate :store, to: :taxonomy
+
has_many :menu_items, as: :linked_resource
has_many :cms_sections, as: :linked_resource
diff --git a/core/spec/models/spree/taxon_spec.rb b/core/spec/models/spree/taxon_spec.rb
index 3ce44cc276..c8d290f6b3 100644
--- a/core/spec/models/spree/taxon_spec.rb
+++ b/core/spec/models/spree/taxon_spec.rb
@@ -347,4 +347,13 @@ describe Spree::Taxon, type: :model do
end
end
end
+
+ describe '#store' do
+ let(:taxonomy) { create(:taxonomy) }
+ let(:taxon) { build(:taxon, taxonomy: taxonomy) }
+
+ it 'returns the store from the taxonomy' do
+ expect(taxon.store).to eq(taxonomy.store)
+ end
+ end
end