added some tests for uploads

This commit is contained in:
Régis Hanol
2013-04-07 17:52:46 +02:00
parent d5c0dd7fa0
commit 1692350336
5 changed files with 122 additions and 47 deletions

View File

@@ -4,7 +4,9 @@ class UploadsController < ApplicationController
def create
requires_parameter(:topic_id)
file = params[:file] || params[:files].first
upload = Upload.create_for(current_user, file, params[:topic_id])
# only supports images for now
return render status: 415, json: failed_json unless file.content_type =~ /^image\/.+/
upload = Upload.create_for(current_user.id, file, params[:topic_id])
render_serialized(upload, UploadSerializer, root: false)
end
end