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.

Remove promotion touching when applying promo on checkout (#13095)

Damian Legawiecc5f0ce7f6a13
diff --git a/core/app/models/spree/adjustment.rb b/core/app/models/spree/adjustment.rb
index 70c3540f86..d7c837dd7f 100644
--- a/core/app/models/spree/adjustment.rb
+++ b/core/app/models/spree/adjustment.rb
@@ -107,7 +107,6 @@ module Spree
attributes[:eligible] = source.promotion.eligible?(target) if promotion?
update_columns(attributes)
- source.promotion.touch if promotion?
amount
end
diff --git a/core/spec/models/spree/adjustment_spec.rb b/core/spec/models/spree/adjustment_spec.rb
index fdb7fe1926..84ac143722 100644
--- a/core/spec/models/spree/adjustment_spec.rb
+++ b/core/spec/models/spree/adjustment_spec.rb
@@ -207,10 +207,6 @@ describe Spree::Adjustment, type: :model do
subject
expect(adjustment.eligible).to eq true
end
-
- it 'touches the promotion' do
- expect { subject }.to change { promotion.reload.updated_at }
- end
end
context "the promotion is not eligible" do
@@ -220,10 +216,6 @@ describe Spree::Adjustment, type: :model do
subject
expect(adjustment.eligible).to eq false
end
-
- it 'touches the promotion' do
- expect { subject }.to change { promotion.reload.updated_at }
- end
end
end
end
diff --git a/core/spec/models/spree/promotion_spec.rb b/core/spec/models/spree/promotion_spec.rb
index e5ca8c16ea..fd048cbac4 100644
--- a/core/spec/models/spree/promotion_spec.rb
+++ b/core/spec/models/spree/promotion_spec.rb
@@ -289,12 +289,6 @@ describe Spree::Promotion, type: :model do
expect(promotion.activate(payload)).to be true
expect(promotion.orders.first).to eql order
end
-
- it 'touches the promotion' do
- previous_updated_at = promotion.updated_at
- expect(promotion.activate(payload)).to be true
- expect(promotion.reload.updated_at).not_to eq(previous_updated_at)
- end
end
context 'when not activated' do
@@ -305,12 +299,6 @@ describe Spree::Promotion, type: :model do
expect(promotion.activate(payload)).to be_falsey
expect(promotion.orders).to be_empty
end
-
- it "doesn't the promotion" do
- previous_updated_at = promotion.updated_at
- expect(promotion.activate(payload)).to be_falsey
- expect(promotion.reload.updated_at).to eq(previous_updated_at)
- end
end
end