Acceptance tests for user

This commit is contained in:
2015-09-17 17:46:33 +02:00
parent 8e931cabd4
commit cb744943bd
35 changed files with 91 additions and 49 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ module Admin
sign_in user
render layout: false
else
render nothing: true
head :not_found
end
end
+1 -1
View File
@@ -59,7 +59,7 @@ private
end
def _render_with_renderer_json(resource, options)
return super if resource.is_a?(Hash)
return super if resource.is_a?(Hash) or resource.is_a?(String)
options[:serializer] ||= begin
if resource.is_a?(SimplyStored::Couch)
#infer based on controller path replacing actual controller part with resouce part /lists/:id/table
+6 -1
View File
@@ -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
+1 -1
View File
@@ -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