Sha256: cb4a8ca5e2d0e836078910e31739dd2fb38b5afc7b9409fae19a669f84a88142

Contents?: true

Size: 1.68 KB

Versions: 9

Compression:

Stored size: 1.68 KB

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(:line_items) { build_stubbed_list(:line_item, 2) }
    let(:order) { build_stubbed(:order, line_items: line_items) }
    let(:rates_for_order_zone) { [] }
    let(:rates_for_default_zone) { [] }
    let(:item_adjuster) { Spree::Tax::ItemAdjuster.new(line_items.first) }

    before do
      expect(Spree::TaxRate).to receive(:for_address).with(order.tax_address).and_return(rates_for_order_zone)
    end

    it 'calls the item adjuster with all line items' do
      expect(Spree::Tax::ItemAdjuster).to receive(:new).
                                            with(
                                              line_items.first,
                                              rates_for_order: rates_for_order_zone,
                                              rates_for_default_zone: rates_for_default_zone
                                            ).and_return(item_adjuster)
      expect(Spree::Tax::ItemAdjuster).to receive(:new).
                                            with(
                                              line_items.second,
                                              rates_for_order: rates_for_order_zone,
                                              rates_for_default_zone: rates_for_default_zone
                                            ).and_return(item_adjuster)

      expect(item_adjuster).to receive(:adjust!).twice
      adjuster.adjust!
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
solidus_core-2.2.2 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.1.1 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.2.1 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.2.0 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.2.0.rc1 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.2.0.beta1 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.1.0 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.1.0.rc1 spec/models/spree/tax/order_adjuster_spec.rb
solidus_core-2.1.0.beta1 spec/models/spree/tax/order_adjuster_spec.rb