Commit ac236e03 authored by jplang's avatar jplang

Added a test for JSON upload.

git-svn-id: https://svn.redmine.org/redmine/trunk@10407 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent ef1c6eaa
......@@ -100,6 +100,23 @@ class ApiTest::AttachmentsTest < ActionController::IntegrationTest
assert_equal 'File content', File.read(attachment.diskfile)
end
test "POST /uploads.json should return the token" do
set_tmp_attachments_directory
assert_difference 'Attachment.count' do
post '/uploads.json', 'File content', {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
assert_response :created
assert_equal 'application/json', response.content_type
end
json = ActiveSupport::JSON.decode(response.body)
assert_kind_of Hash, json['upload']
token = json['upload']['token']
assert_not_nil token
attachment = Attachment.first(:order => 'id DESC')
assert_equal token, attachment.token
end
test "POST /uploads.xml should not accept other content types" do
set_tmp_attachments_directory
assert_no_difference 'Attachment.count' do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment