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.

Fixed: touch Store after creating Custom Domain

Damian Legawiec55809e698caa
diff --git a/core/app/models/spree/custom_domain.rb b/core/app/models/spree/custom_domain.rb
index 5532046ef6..bb75fb1ced 100644
--- a/core/app/models/spree/custom_domain.rb
+++ b/core/app/models/spree/custom_domain.rb
@@ -8,7 +8,7 @@ module Spree
#
# Associations
#
- belongs_to :store, class_name: 'Spree::Store', inverse_of: :custom_domains
+ belongs_to :store, class_name: 'Spree::Store', inverse_of: :custom_domains, touch: true
#
# Validations
diff --git a/core/spec/models/spree/custom_domain_spec.rb b/core/spec/models/spree/custom_domain_spec.rb
index 17294a0568..0206d99421 100644
--- a/core/spec/models/spree/custom_domain_spec.rb
+++ b/core/spec/models/spree/custom_domain_spec.rb
@@ -23,4 +23,16 @@ RSpec.describe Spree::CustomDomain, type: :model do
end
end
end
+
+ describe 'Callbacks' do
+ let(:store) { create(:store) }
+ let(:custom_domain) { build(:custom_domain, store: store) }
+
+ describe 'touch store' do
+ it 'touches the store when the custom domain is created' do
+ expect(store).to receive(:touch)
+ custom_domain.save!
+ end
+ end
+ end
end