Sha256: e897e600755045c0382cb18fd06e46c80933269e83d4a4507245046f556cd5ab

Contents?: true

Size: 936 Bytes

Versions: 6

Compression:

Stored size: 936 Bytes

Contents

require 'spec_helper'

RSpec.describe Spree::Tax::OrderAdjuster do
  subject(:adjuster) { described_class.new(order) }

  describe 'initialization' do
    let(:order) { Spree::Order.new }

    it 'sets order to adjustable' do
      expect(adjuster.order).to eq(order)
    end
  end

  describe '#adjust!' do
    let(:order) { Spree::Order.new }

    let(:custom_calculator_class) { double }
    let(:custom_calculator_instance) { double }

    before do
      Spree::Config.tax_calculator_class = custom_calculator_class
    end

    it 'calls the configured tax calculator' do
      expect(custom_calculator_class).to receive(:new).with(order).at_least(:once).and_return(custom_calculator_instance)
      expect(custom_calculator_instance).to receive(:calculate).at_least(:once).and_return(
        Spree::Tax::OrderTax.new(order_id: order.id, line_item_taxes: [], shipment_taxes: [])
      )

      adjuster.adjust!
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
solidus_core-2.3.1 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.3.0 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.3.0.rc3 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.3.0.rc2 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.3.0.rc1 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.3.0.beta1 spec/models/spree/tax/order_adjuster_spec.rb