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 5d21e5f
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,30 @@
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: [best_promotion_action]) }
let(:best_promotion_action) { Spree::Promotion::Actions::CreateItemAdjustments.new(calculator: best_calculator) }
let(:best_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: [worst_promotion_action]) }
let(:worst_promotion_action) { Spree::Promotion::Actions::CreateItemAdjustments.new(calculator: worst_calculator) }
let(:worst_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 5d21e5f

Please sign in to comment.