Sha256: 1898a509ee464ce4b8bde6e50cba652aec5158976e16f94dc4f9574efc1f132c
Contents?: true
Size: 1.88 KB
Versions: 1
Compression:
Stored size: 1.88 KB
Contents
# frozen_string_literal: true require 'spec_helper' RSpec.describe Spree::Shipment do describe '#easypost_shipment' do context 'when no shipping rate was selected' do it 'returns nil' do shipment = create(:shipment) expect(shipment.easypost_shipment).to be_nil end end context 'when a shipping rate was selected' do it 'returns the shipment associated with the shipping rate' do easypost_shipment = stub_easypost_shipment shipment = create( :shipment, :with_easypost, easypost_shipment_id: easypost_shipment.id, ) expect(shipment.easypost_shipment).to eq(easypost_shipment) end end end describe '#ship!' do context 'when purchase_labels is true' do it 'buys the selected rate' do stub_easypost_config(purchase_labels: true) easypost_shipment = stub_easypost_shipment selected_easypost_rate = easypost_shipment.rates.first shipment = create( :shipment, :with_easypost, state: 'ready', easypost_shipment_id: easypost_shipment.id, easypost_rate_id: selected_easypost_rate.id, ) shipment.ship! expect(easypost_shipment).to have_received(:buy).with(selected_easypost_rate) end end context 'when purchase_labels is false' do it 'does not buy rates automatically' do stub_easypost_config(purchase_labels: false) easypost_shipment = stub_easypost_shipment selected_easypost_rate = easypost_shipment.rates.first shipment = create( :shipment, :with_easypost, state: 'ready', easypost_shipment_id: easypost_shipment.id, easypost_rate_id: selected_easypost_rate.id, ) shipment.ship! expect(easypost_shipment).not_to have_received(:buy) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_easypost-3.0.0 | spec/models/spree/shipment_spec.rb |