Skip to content

Commit

Permalink
Merge pull request #682 from brendandeere/allow_zero_dollar_order_adj…
Browse files Browse the repository at this point in the history
…ustments

[RFC] Allow zero dollar order adjustments
  • Loading branch information
jhawthorn committed Jan 26, 2016
2 parents 31fdf9d + 860524e commit 974b928
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def perform(options = {})
return if promotion_credit_exists?(order)

amount = compute_amount(order)
return if amount == 0
Spree::Adjustment.create!(
amount: amount,
order: order,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
allow(action).to receive_messages(:promotion => promotion)
end

# Regression test for https://github.com/spree/spree/issues/3966
it "does not apply an adjustment if the amount is 0" do
it "does apply an adjustment if the amount is 0" do
action.calculator.preferred_amount = 0
action.perform(payload)
expect(promotion.usage_count).to eq(0)
expect(order.adjustments.count).to eq(0)
expect(order.adjustments.count).to eq(1)
end

it "should create a discount with correct negative amount" do
Expand Down
5 changes: 5 additions & 0 deletions core/spec/models/spree/promotion_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,11 @@

context 'when the order is not complete' do
let(:order) { create :order, user: user }

# The before clause above sets the completed at
# value for this order
before { order.update completed_at: nil }

it { is_expected.to be false }
end
end
Expand Down

0 comments on commit 974b928

Please sign in to comment.