diff --git a/spec/controllers/api/shipments_controller_spec.rb b/spec/controllers/api/shipments_controller_spec.rb index d79eaf0c08..2f66d0b158 100644 --- a/spec/controllers/api/shipments_controller_spec.rb +++ b/spec/controllers/api/shipments_controller_spec.rb @@ -5,7 +5,6 @@ describe Api::ShipmentsController, type: :controller do let!(:shipment) { create(:shipment) } let!(:attributes) { [:id, :tracking, :number, :cost, :shipped_at, :stock_location_name, :order_id] } - let!(:resource_scoping) { { order_id: shipment.order.to_param, id: shipment.to_param } } let(:current_api_user) { build(:user) } before do @@ -14,12 +13,12 @@ describe Api::ShipmentsController, type: :controller do context "as a non-admin" do it "cannot make a shipment ready" do - api_put :ready + api_put :ready, order_id: shipment.order.to_param, id: shipment.to_param assert_unauthorized! end it "cannot make a shipment shipped" do - api_put :ship + api_put :ship, order_id: shipment.order.to_param, id: shipment.to_param assert_unauthorized! end end @@ -92,7 +91,7 @@ describe Api::ShipmentsController, type: :controller do it "can make a shipment ready" do allow_any_instance_of(Spree::Order).to receive_messages(paid?: true, complete?: true) - api_put :ready + api_put :ready, order_id: shipment.order.to_param, id: shipment.to_param expect(attributes.all?{ |attr| json_response.key? attr.to_s }).to be_truthy expect(json_response["state"]).to eq("ready") @@ -101,7 +100,7 @@ describe Api::ShipmentsController, type: :controller do it "cannot make a shipment ready if the order is unpaid" do allow_any_instance_of(Spree::Order).to receive_messages(paid?: false) - api_put :ready + api_put :ready, order_id: shipment.order.to_param, id: shipment.to_param expect(json_response["error"]).to eq("Cannot ready shipment.") expect(response.status).to eq(422) @@ -109,10 +108,9 @@ describe Api::ShipmentsController, type: :controller do context 'for completed shipments' do let(:order) { create :completed_order_with_totals } - let!(:resource_scoping) { { order_id: order.to_param, id: order.shipments.first.to_param } } it 'adds a variant to a shipment' do - api_put :add, variant_id: variant.to_param, quantity: 2 + api_put :add, variant_id: variant.to_param, quantity: 2, order_id: order.to_param, id: order.shipments.first.to_param expect(response.status).to eq(200) expect(order.shipment.reload.inventory_units.select { |h| h['variant_id'] == variant.id }.size).to eq 2 @@ -120,7 +118,7 @@ describe Api::ShipmentsController, type: :controller do it 'removes a variant from a shipment' do order.contents.add(variant, 2) - api_put :remove, variant_id: variant.to_param, quantity: 1 + api_put :remove, variant_id: variant.to_param, quantity: 1, order_id: order.to_param, id: order.shipments.first.to_param expect(response.status).to eq(200) expect(order.shipment.reload.inventory_units.select { |h| h['variant_id'] == variant.id }.size).to eq(1)