Sha256: 2850ee3a90782f75e7661463a47fb290bc3005ba086ea86e31c01c28f2eb9c1d

Contents?: true

Size: 1.14 KB

Versions: 43

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require 'rails_helper'
require 'shared_examples/calculator_shared_examples'

RSpec.describe Spree::Calculator::Shipping::PriceSack, type: :model do
  let(:calculator) do
    calculator = Spree::Calculator::PriceSack.new
    calculator.preferred_minimal_amount = 5
    calculator.preferred_normal_amount = 10
    calculator.preferred_discount_amount = 1
    calculator
  end

  it_behaves_like 'a calculator with a description'

  let(:order) { stub_model(Spree::Order) }
  let(:shipment) { stub_model(Spree::Shipment, amount: 10) }

  # Regression test for https://github.com/spree/spree/issues/714 and https://github.com/spree/spree/issues/739
  it "computes with an order object" do
    calculator.compute(order)
  end

  # Regression test for https://github.com/spree/spree/issues/1156
  it "computes with a shipment object" do
    calculator.compute(shipment)
  end

  # Regression test for https://github.com/spree/spree/issues/2055
  it "computes the correct amount" do
    expect(calculator.compute(2)).to eq(calculator.preferred_normal_amount)
    expect(calculator.compute(6)).to eq(calculator.preferred_discount_amount)
  end
end

Version data entries

43 entries across 43 versions & 2 rubygems

Version Path
solidus_core-2.8.1 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core-2.6.3 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core-2.8.0 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core-2.7.1 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core-2.6.2 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.14 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.13 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.12 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.11 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.10 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.9 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.8 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.7 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.6 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.5 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.4 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.3 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.1 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.0 spec/models/spree/calculator/shipping/price_sack_spec.rb
solidus_core-2.7.0 spec/models/spree/calculator/shipping/price_sack_spec.rb