Controller spec api improvements
This commit is contained in:
@@ -104,7 +104,7 @@ module Suppliers
|
||||
@tables = current_supplier.active_tables
|
||||
render action: "new"
|
||||
end
|
||||
format.json { render json: @list.errors, status: :unprocessable_entity }
|
||||
format.json { render json: {errors: @list.errors}, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -123,13 +123,10 @@ module Suppliers
|
||||
respond_to do |format|
|
||||
if @list.update_attributes(list_params)
|
||||
format.html { redirect_to [:suppliers, @list], notice: t('action.update.successfull', model: List.model_name.human) }
|
||||
format.json { head :no_content }
|
||||
format.js { head :no_content }
|
||||
format.json { render json: @list }
|
||||
else
|
||||
@tables = current_supplier.active_tables
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @list.errors, status: :unprocessable_entity }
|
||||
format.js { head :no_content }
|
||||
format.json { render json: {errors: @list.errors}, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -149,7 +146,7 @@ module Suppliers
|
||||
private
|
||||
|
||||
def list_params
|
||||
params.require(:list).permit(:state, :needs_help, :needs_payment, :closed_at, :join_requests, :price, :is_paid, :paid_at, :table_id, :section_id)
|
||||
params.require(:list).permit(:state, :needs_help, :needs_payment, :closed_at, :join_requests, :price, :is_paid, :paid_at, :table_id, :section_id, :foo)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,7 +61,7 @@ module Suppliers
|
||||
format.json { render json: @section, serializer: SupplierSectionSerializer, status: :created }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @section.errors, status: :unprocessable_entity }
|
||||
format.json { render json: {errors: @section.errors}, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -77,7 +77,7 @@ module Suppliers
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @section.errors, status: :unprocessable_entity }
|
||||
format.json { render json: {errors: @section.errors}, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user