Sha256: cab27000a588e047b8aded167a56a70a7e95086611f9f8c6ae9132dc4876da23
Contents?: true
Size: 1.34 KB
Versions: 15
Compression:
Stored size: 1.34 KB
Contents
require 'spec_helper' module Spree module PromotionHandler describe FreeShipping, type: :model do let(:order) { create(:order) } let(:shipment) { create(:shipment, order: order ) } let(:action) { Spree::Promotion::Actions::FreeShipping.new } subject { Spree::PromotionHandler::FreeShipping.new(order) } context 'with apply_automatically' do let!(:promotion) { create(:promotion, apply_automatically: true, promotion_actions: [action]) } it "creates the adjustment" do expect { subject.activate }.to change { shipment.adjustments.count }.by(1) end end context 'with a code' do let!(:promotion) { create(:promotion, code: 'freeshipping', promotion_actions: [action]) } context 'when already applied' do before do order.order_promotions.create!(promotion: promotion, promotion_code: promotion.codes.first) end it 'adjusts the shipment' do expect { subject.activate }.to change { shipment.adjustments.count } end end context 'when not already applied' do it 'does not adjust the shipment' do expect { subject.activate }.to_not change { shipment.adjustments.count } end end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems