Sha256: f92b59b39820308b1b95f74897bd5f29cd370d2d8700d796b13aab3c166c13e7

Contents?: true

Size: 846 Bytes

Versions: 1

Compression:

Stored size: 846 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Spree::Order, :vcr do
  let(:order) do
    create(:order_with_line_items, line_items_count: 1) do |order|
      order.variants.each { |v| v.update! weight: 10 }
    end
  end

  describe '#refresh_shipment_rates' do
    it "can get rates from easy post" do
      order.refresh_shipment_rates

      rates = order.shipments.first.shipping_rates

      expect(rates.all? { |rate| rate.cost.present? }).to be_present
      expect(rates.all?(&:easy_post_shipment_id?)).to be_present
      expect(rates.all?(&:easy_post_rate_id?)).to be_present
    end

    it 'create shipping methods for the rates' do
      order.refresh_shipment_rates

      rates = order.shipments.first.shipping_rates

      expect(rates).to(be_all { |rate| rate.shipping_method.present? })
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_easypost-2.0.0 spec/models/spree/order_spec.rb