Defect #33752 » attachments_test.rb.patch
| trunk/test/integration/api_test/attachments_test.rb (revision 19920) → trunk/test/integration/api_test/attachments_test.rb (working copy) | ||
|---|---|---|
|
assert attachment.digest.present?
|
||
|
assert File.exist? attachment.diskfile
|
||
|
end
|
||
|
test "POST /uploads.json should be compatible with an fcgi's input" do
|
||
|
set_tmp_attachments_directory
|
||
|
assert_difference 'Attachment.count' do
|
||
|
post '/uploads.json', :headers => {
|
||
|
"CONTENT_TYPE" => 'application/octet-stream',
|
||
|
"CONTENT_LENGTH" => '12',
|
||
|
"rack.input" => Rack::RewindableInput.new(StringIO.new('File content'))
|
||
|
}.merge(credentials('jsmith'))
|
||
|
assert_response :created
|
||
|
end
|
||
|
json = ActiveSupport::JSON.decode(response.body)
|
||
|
assert_kind_of Hash, json['upload']
|
||
|
token = json['upload']['token']
|
||
|
assert token.present?
|
||
|
assert attachment = Attachment.find_by_token(token)
|
||
|
assert_equal 12, attachment.filesize
|
||
|
assert File.exist? attachment.diskfile
|
||
|
end
|
||
|
end
|
||