Skip to content

Commit

Permalink
Alias NullPromotionHandler#activate to #apply
Browse files Browse the repository at this point in the history
The four promotion handlers in core have two different methods to set
them into motion. Cart, Shipping, and Page use #activate, but Coupon
uses #apply. We only need one null promotion handler, and since we just
want it to return the unchanged promotion, we just alias.
  • Loading branch information
mamhoff committed Mar 12, 2024
1 parent f043282 commit b713be7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/app/models/spree/null_promotion_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def initialize(order)
def activate
@order
end
alias_method :apply, :activate

def can_apply?
true
Expand Down
8 changes: 8 additions & 0 deletions core/spec/models/spree/null_promotion_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
end
end

describe "#apply" do
subject(:activate) { handler.apply }

it "returns the unchanged order" do
expect(activate).to eq(order)
end
end

describe "#can_apply?" do
subject { handler.can_apply? }
let(:order) { double(Spree::Order, coupon_code: nil) }
Expand Down

0 comments on commit b713be7

Please sign in to comment.