Sha256: e318a94cdc64eb1c0b0c76940f0bd44fc3faa6602fea6e788f3fe1152559fd55
Contents?: true
Size: 1.45 KB
Versions: 22
Compression:
Stored size: 1.45 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(:promotion) { Promotion.create(name: "Free Shipping") } let(:calculator) { Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10) } let!(:action) { Promotion::Actions::FreeShipping.create(promotion: promotion) } subject { Spree::PromotionHandler::FreeShipping.new(order) } context "activates in Shipment level" do it "creates the adjustment" do expect { subject.activate }.to change { shipment.adjustments.count }.by(1) end end context "if promo has a code" do before do promotion.update_column(:code, "code") end it "does adjust the shipment when applied to order" do order.promotions << promotion expect { subject.activate }.to change { shipment.adjustments.count } end it "does not adjust the shipment when not applied to order" do expect { subject.activate }.to_not change { shipment.adjustments.count } end end context "if promo has a path" do before do promotion.update_column(:path, "path") end it "does not adjust the shipment" do expect { subject.activate }.to_not change { shipment.adjustments.count } end end end end end
Version data entries
22 entries across 22 versions & 1 rubygems