Redmine 4.1.7
This commit is contained in:
parent
55458d3479
commit
3ca3c37487
103 changed files with 2426 additions and 431 deletions
|
@ -229,4 +229,51 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base
|
|||
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
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue