Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not call Spree::PromotionHandler::Shipping when SFP is active #61

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ def reset_current_discounts
shipments.each(&:reset_current_discounts)
end

def apply_shipping_promotions
if Spree::Config.promotion_adjuster_class <= SolidusFriendlyPromotions::OrderDiscounter
recalculate
else
super
end
end

Spree::Order.prepend self
end
end
23 changes: 23 additions & 0 deletions spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,27 @@
expect { subject }.to change { SolidusFriendlyPromotions::OrderPromotion.count }.from(1).to(0)
end
end

describe "#apply_shipping_promotions" do
let(:order) { build(:order) }
subject { order.apply_shipping_promotions }

it "does not call Spree::PromotionHandler::Shipping" do
expect(Spree::PromotionHandler::Shipping).not_to receive(:new)
subject
end

context "if solidus_friendly_promotions is not active" do
around do |example|
Spree::Config.promotion_adjuster_class = Spree::Promotion::OrderAdjustmentsRecalculator
example.run
Spree::Config.promotion_adjuster_class = SolidusFriendlyPromotions::OrderDiscounter
end

it "does call the promotion handler shipping" do
expect(Spree::PromotionHandler::Shipping).to receive(:new).and_call_original
subject
end
end
end
end