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

Version Path
spree_core-3.3.0.rc1 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.1.5 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.2.1 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.2.0 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.1.4 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.2.0.rc3 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.2.0.rc2 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.2.0.rc1 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.1.3 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.1.2 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.0.10 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.1.1 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.1.0 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.1.0.rc4 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.0.9 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.1.0.rc3 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.1.0.rc2 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.1.0.rc1 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.0.8 spec/models/spree/promotion_handler/free_shipping_spec.rb
spree_core-3.0.7 spec/models/spree/promotion_handler/free_shipping_spec.rb