changing table user acceptance specs in the green

This commit is contained in:
2014-06-25 16:11:29 +02:00
parent 0e4993e8a6
commit 58f0937570
9 changed files with 89 additions and 45 deletions
+45 -28
View File
@@ -36,23 +36,51 @@ class UserController < Users::ApplicationController
#end
# GET /user/table_info.json
#def table_info
#respond_to do |format|
#format.json do
#render json: json_alert('messages.table_not_found') and return unless params[:table_id].present?
#@table = Table.find(params[:table_id])
#res = {}
#res[:occupied] = @table.occupied?
#res[:reserved] = @table.reserved?
#res[:supplier_closed] = @table.supplier.closed?
#if list.present?
#res[:other_supplier] = true if list.supplier_id != @table.supplier_id
#res[:current_table_id] = list.table_id
#end
#render json: res
#end
#end
#end
# used for moving table request
# TODO wrap logic of actions
# - table_info
# - move_table
# into separate class and implement security in a non stupid way as it is now
def table_info
respond_to do |format|
format.json do
render json: json_alert('messages.table_not_found') and return unless params[:table_id].present?
@table = Table.find(params[:table_id])
res = {}
res[:occupied] = @table.occupied?
res[:reserved] = @table.reserved?
res[:supplier_closed] = @table.supplier.closed?
if list.present?
res[:other_supplier] = true if list.supplier_id != @table.supplier_id
res[:current_table_id] = list.table_id
end
render json: res
end
end
end
# POST /user/move_table.json
# used to move the table
# TODO wrap logic of actions
# - table_info
# - move_table
# into separate class and implement security in a non stupid way as it is now
def move_table
render json: json_alert('messages.no_active_list', list_active: false) and return unless list.present?
render json: json_alert('messages.table_not_found') and return unless params[:table_id].present?
@table = Table.find(params[:table_id])
if @table.occupied?
render json: {occupied: true}
elsif @table.reserved?
render json: {reserved: true}
elsif list.supplier_id != @table.supplier_id
res[:other_supplier] = true if list.supplier_id != @table.supplier_id
res[:current_table_id] = list.table_id
else
list.move_to_table! @table
render json: {occupied: false, reserved: false}
end
end
# GET /suppliers/1/product_list
# GET /suppliers/1/product_list.json
@@ -285,15 +313,4 @@ class UserController < Users::ApplicationController
end
end
#def move_table
#render json: json_alert('messages.no_active_list', list_active: false) and return unless list.present?
#render json: json_alert('messages.table_not_found') and return unless params[:table_id].present?
#@table = Table.find(params[:table_id])
#if @table.occupied?
#render json: {occupied: true}
#else
#list.move_to_table! @table
#render json: {occupied: false}
#end
#end
end