User specs in the green
This commit is contained in:
@@ -137,6 +137,23 @@ module Suppliers
|
||||
head :no_content
|
||||
end
|
||||
|
||||
# POST /list/:id/change_table?to_table=:table_id
|
||||
def change_table
|
||||
res = {}
|
||||
status = 200
|
||||
@list = List.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@table = Table.find(params[:table_id])
|
||||
res[:table_is_from_other_supplier] = true unless @table.supplier_id == @list.supplier_id
|
||||
res[:table_occupied] = true if @table.occupied?
|
||||
unless res[:table_is_from_other_supplier] or res[:table_occupied]
|
||||
res[:ok] = true
|
||||
@list.move_to_table! @table
|
||||
else
|
||||
res[:ok] = false
|
||||
end
|
||||
render json: res
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def list_params
|
||||
|
||||
Reference in New Issue
Block a user