diff --git a/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb b/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb index ca01662..1f3ab6c 100644 --- a/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb +++ b/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb @@ -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