mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fix issue with nil current_order where shipping_method serializer requires a current_order to calculate the shipping fees
This commit is contained in:
@@ -2,7 +2,7 @@ module Api
|
||||
class OrdersController < BaseController
|
||||
def show
|
||||
authorize! :read, order
|
||||
render json: order, serializer: Api::OrderDetailedSerializer
|
||||
render json: order, serializer: Api::OrderDetailedSerializer, current_order: order
|
||||
end
|
||||
|
||||
def index
|
||||
|
||||
@@ -218,8 +218,16 @@ module Api
|
||||
expect_order
|
||||
end
|
||||
|
||||
it "can view an order with weight calculator (this validates case where options[current_order] is nil on the shipping method serializer)" do
|
||||
order.shipping_method.update_attribute(:calculator, create(:weight_calculator, calculable: order))
|
||||
allow(controller).to receive(:current_order).and_return order
|
||||
get :show, id: order.number
|
||||
expect_order
|
||||
end
|
||||
|
||||
it "returns an order with all required fields" do
|
||||
get :show, id: order.number
|
||||
|
||||
expect_order
|
||||
expect(json_response.symbolize_keys.keys).to include(*order_detailed_attributes)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user