Skip to content

Commit

Permalink
Implement a discount test
Browse files Browse the repository at this point in the history
This spec fails with the previous version of the code.
  • Loading branch information
kennyadsl committed May 11, 2023
1 parent ef5e5dc commit 3cf8e3e
Showing 1 changed file with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,40 @@
end

context 'when an order has an inapplicable promo adjustment' do
let(:best_promotion) {
create(:promotion,
:with_line_item_adjustment,
:with_item_total_rule, adjustment_rate: 2.5, item_total_threshold_amount: 10,
apply_automatically: true,
promotion_actions: [
Spree::Promotion::Actions::CreateItemAdjustments.new(
calculator: Spree::Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10)
)
])
}

let(:worst_promotion) {
create(:promotion,
:with_line_item_adjustment,
:with_item_total_rule, adjustment_rate: 2.5, item_total_threshold_amount: 10,
apply_automatically: true,
promotion_actions: [
Spree::Promotion::Actions::CreateItemAdjustments.new(
calculator: Spree::Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 5)
)
])
}

before do
best_promotion.activate(order: order)
worst_promotion.activate(order: order)
order.recalculate
end

it 'does not include it in the paypal order breakdown' do
# TODO
expect(to_json.dig(:purchase_units, 0).dig(:amount, :breakdown)).to match hash_including(
discount: { currency_code: "USD", value: "2.50" }
)
end
end
end
Expand Down

0 comments on commit 3cf8e3e

Please sign in to comment.