Skip to content

Commit

Permalink
NullPromotionHandler: return self from #apply
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mamhoff committed Jun 4, 2024
1 parent 2bef8d5 commit fd5d77e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion core/app/models/spree/null_promotion_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ def initialize(order)
def activate
@order
end
alias_method :apply, :activate

def apply
self
end

def can_apply?
true
Expand Down
5 changes: 3 additions & 2 deletions core/spec/models/spree/null_promotion_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit fd5d77e

Please sign in to comment.