Acceptance tests for user
This commit is contained in:
@@ -14,7 +14,7 @@ module Users
|
||||
#EMBER
|
||||
def current
|
||||
@list = current_user.active_list
|
||||
params[:id] = @list.id # serializer determines collection or not based on the presence of this
|
||||
params[:id] = @list.try(:id) # serializer determines collection or not based on the presence of this
|
||||
show
|
||||
end
|
||||
|
||||
@@ -67,6 +67,11 @@ module Users
|
||||
# POST /user/lists/:id/order_products
|
||||
def order_products
|
||||
res = {}
|
||||
unless active_list.present?
|
||||
res[:list_closed] = true
|
||||
render json: res, status: 404
|
||||
return
|
||||
end
|
||||
res[:supplier_closed] = active_list.supplier.closed?
|
||||
unless res[:supplier_closed]
|
||||
# Create new list
|
||||
|
||||
@@ -75,7 +75,7 @@ module Users
|
||||
list = List.from_table( table, current_user )
|
||||
res[:active_list_id] = list.id # used to set the active list in the app
|
||||
order = list.place_order product_orders: product_orders, user: current_user, first_order: true
|
||||
res[:payload] = JSONAPI::Serializer.serialize(order, serializer: Users::OrderSerializer, include: %w[list product_orders])
|
||||
res[:payload] = JSONAPI::Serializer.serialize(order, serializer: Users::OrderSerializer, include: %w[list list.users product_orders])
|
||||
end
|
||||
render json: res
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user