diff --git a/core/app/models/spree/order/checkout.rb b/core/app/models/spree/order/checkout.rb index 6aeaa9e798c..f0b97ec1fde 100644 --- a/core/app/models/spree/order/checkout.rb +++ b/core/app/models/spree/order/checkout.rb @@ -108,9 +108,6 @@ def define_state_machine! # calls matter so that we do not process payments # until validations have passed before_transition to: :complete, do: :validate_line_item_availability - if states[:delivery] - before_transition to: :complete, do: :ensure_available_shipping_rates - end before_transition to: :complete, do: :ensure_promotions_eligible before_transition to: :complete, do: :ensure_line_item_variants_are_not_deleted before_transition to: :complete, do: :ensure_inventory_units diff --git a/core/spec/models/spree/order/checkout_spec.rb b/core/spec/models/spree/order/checkout_spec.rb index 7567d9d244e..f09cc1f3b86 100644 --- a/core/spec/models/spree/order/checkout_spec.rb +++ b/core/spec/models/spree/order/checkout_spec.rb @@ -589,22 +589,6 @@ def assert_state_changed(order, from, to) end end - context 'a shipment has no shipping rates' do - let(:order) { create(:order_with_line_items, state: 'confirm') } - let(:shipment) { order.shipments.first } - - before do - shipment.shipping_rates.destroy_all - end - - it 'clears the shipments and fails the transition' do - expect(order.complete).to eq(false) - expect(order.errors[:base]).to include(Spree.t(:items_cannot_be_shipped)) - expect(order.shipments.count).to eq(0) - expect(Spree::InventoryUnit.where(shipment_id: shipment.id).count).to eq(0) - end - end - context 'the order is already paid' do let(:order) { create(:order_with_line_items) } diff --git a/frontend/spec/controllers/spree/checkout_controller_spec.rb b/frontend/spec/controllers/spree/checkout_controller_spec.rb index cb8b8c9dc16..be378cce0b0 100644 --- a/frontend/spec/controllers/spree/checkout_controller_spec.rb +++ b/frontend/spec/controllers/spree/checkout_controller_spec.rb @@ -330,39 +330,18 @@ def post_address expect(response).to redirect_to(spree.checkout_state_path('address')) end end - end - - context "fails to transition to complete from confirm" do - let(:order) do - FactoryGirl.create(:order_with_line_items).tap(&:next!) - end - - before do - allow(controller).to receive_messages current_order: order - allow(controller).to receive_messages check_authorization: true - end context "when the country is not a shippable country" do - before do - order.ship_address.tap do |address| - # A different country which is not included in the list of shippable countries - australia = create(:country, name: "Australia") - # update_columns to get around readonly restriction when testing - address.update_columns(country_id: australia.id, state_name: 'Victoria') - end + let(:foreign_address) { create(:address, country_iso_code: "CA") } - payment_method = FactoryGirl.create(:simple_credit_card_payment_method) - payment = FactoryGirl.create(:payment, payment_method: payment_method) - order.payments << payment + before do + order.update(shipping_address: foreign_address) end it "due to no available shipping rates for any of the shipments" do - expect(order.shipments.count).to eq(1) - order.shipments.first.shipping_rates.delete_all - order.update_attributes(state: 'confirm') - put :update, params: { state: order.state, order: {} } + put :update, params: { state: "address", order: {} } expect(flash[:error]).to eq(Spree.t(:items_cannot_be_shipped)) - expect(response).to redirect_to(spree.checkout_state_path('confirm')) + expect(response).to redirect_to(spree.checkout_state_path('address')) end end end