Sha256: d4add4a96e12ac73c59c7e4a4175abd72332ae375bd37c395f4ee3dd4b8daebf

Contents?: true

Size: 977 Bytes

Versions: 14

Compression:

Stored size: 977 Bytes

Contents

# frozen_string_literal: true

require 'rails_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
      stub_spree_preferences(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

14 entries across 14 versions & 1 rubygems

Version Path
solidus_core-2.10.5 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.10.3 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.10.2 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.9.6 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.10.1 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.9.5 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.10.0 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.9.4 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.9.3 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.9.2 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.10.0.beta1 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.9.1 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.9.0 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.9.0.rc.1 spec/models/spree/tax/order_adjuster_spec.rb