Sha256: 547a796d36ebdf14cc8ea0d85fea28d359c126d0289b2847e818473d07056198
Contents?: true
Size: 1.28 KB
Versions: 6
Compression:
Stored size: 1.28 KB
Contents
require 'spec_helper' describe Spree::Promotion::Actions::FreeShipping, type: :model do let(:order) { create(:completed_order_with_totals) } let(:promotion) { create(:promotion) } let(:action) { Spree::Promotion::Actions::FreeShipping.create } let(:payload) { { order: order } } it_behaves_like 'an adjustment source' # From promotion spec: context "#perform" do before do order.shipments << create(:shipment) promotion.promotion_actions << action end it "should create a discount with correct negative amount" do expect(order.shipments.count).to eq(2) expect(order.shipments.first.cost).to eq(100) expect(order.shipments.last.cost).to eq(100) expect(action.perform(payload)).to be true expect(promotion.credits_count).to eq(2) expect(order.shipment_adjustments.count).to eq(2) expect(order.shipment_adjustments.first.amount.to_i).to eq(-100) expect(order.shipment_adjustments.last.amount.to_i).to eq(-100) end it "should not create a discount when order already has one from this promotion" do expect(action.perform(payload)).to be true expect(action.perform(payload)).to be false expect(promotion.credits_count).to eq(2) expect(order.shipment_adjustments.count).to eq(2) end end end
Version data entries
6 entries across 6 versions & 1 rubygems