diff options
author | Go MAEDA <maeda@farend.jp> | 2021-08-14 01:38:26 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2021-08-14 01:38:26 +0000 |
commit | c46e55e496c26e003857285cbf0e14045b9f9f86 (patch) | |
tree | e9c80553ca88b86d155952a4ed717ddb5e96e53f /test | |
parent | 75e6cf81e79658e684cf6a94fcc9fa28f7fcdf8f (diff) | |
download | redmine-c46e55e496c26e003857285cbf0e14045b9f9f86.tar.gz redmine-c46e55e496c26e003857285cbf0e14045b9f9f86.zip |
File upload fails when run with uWSGI (#35715).
Contributed by Pavel Rosický and Holger Just.
git-svn-id: http://svn.redmine.org/redmine/trunk@21173 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/api_test/attachments_test.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/integration/api_test/attachments_test.rb b/test/integration/api_test/attachments_test.rb index 538649950..1589e3f72 100644 --- a/test/integration/api_test/attachments_test.rb +++ b/test/integration/api_test/attachments_test.rb @@ -272,4 +272,29 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base assert_equal 12, attachment.filesize assert File.exist? attachment.diskfile end + + test "POST /uploads.json should be compatible with a uwsgi's input" do + set_tmp_attachments_directory + assert_difference 'Attachment.count' do + request_body = Rack::RewindableInput.new(StringIO.new('File content')) + # Uwsgi_IO object does not have size method + request_body.instance_eval('undef :size', __FILE__, __LINE__) + post( + '/uploads.json', + :headers => { + "CONTENT_TYPE" => 'application/octet-stream', + "CONTENT_LENGTH" => '12', + "rack.input" => request_body + }.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 |