From fd5d77ed63b83239c3757799a04c7da9bef21af7 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Thu, 16 May 2024 14:48:25 +0200 Subject: [PATCH] NullPromotionHandler: return self from #apply The existing promotion handlers are activated using either `#apply` or `#activate`. The return value `#activate` is usually not read, and is thus not really important, but that of `#apply` must be the handler itself, so that e.g. the adjustments admin has access to any application errors. --- core/app/models/spree/null_promotion_handler.rb | 5 ++++- core/spec/models/spree/null_promotion_handler_spec.rb | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/app/models/spree/null_promotion_handler.rb b/core/app/models/spree/null_promotion_handler.rb index f40087f745a..f1a7d0b5a11 100644 --- a/core/app/models/spree/null_promotion_handler.rb +++ b/core/app/models/spree/null_promotion_handler.rb @@ -12,7 +12,10 @@ def initialize(order) def activate @order end - alias_method :apply, :activate + + def apply + self + end def can_apply? true diff --git a/core/spec/models/spree/null_promotion_handler_spec.rb b/core/spec/models/spree/null_promotion_handler_spec.rb index 8de56a305c6..9d09f15c3c2 100644 --- a/core/spec/models/spree/null_promotion_handler_spec.rb +++ b/core/spec/models/spree/null_promotion_handler_spec.rb @@ -17,8 +17,9 @@ describe "#apply" do subject(:activate) { handler.apply } - it "returns the unchanged order" do - expect(activate).to eq(order) + it "returns the handler with the unchanged order" do + expect(activate).to eq(handler) + expect(activate.order).to eq(order) end end