User specs in the green

This commit is contained in:
2015-09-21 15:22:43 +02:00
parent cb744943bd
commit 2c3705790c
27 changed files with 112 additions and 30 deletions
@@ -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