Project

General

Profile

Defect #33752 » attachments_test.rb.patch

Pavel Rosický, 2020-07-20 23:57

View differences:

trunk/test/integration/api_test/attachments_test.rb (revision 19920) → trunk/test/integration/api_test/attachments_test.rb (working copy)
232 232
    assert attachment.digest.present?
233 233
    assert File.exist? attachment.diskfile
234 234
  end
235

  
236
  test "POST /uploads.json should be compatible with an fcgi's input" do
237
    set_tmp_attachments_directory
238
    assert_difference 'Attachment.count' do
239
      post '/uploads.json', :headers => {
240
          "CONTENT_TYPE" => 'application/octet-stream',
241
          "CONTENT_LENGTH" => '12',
242
          "rack.input" => Rack::RewindableInput.new(StringIO.new('File content'))
243
        }.merge(credentials('jsmith'))
244
      assert_response :created
245
    end
246
    json = ActiveSupport::JSON.decode(response.body)
247
    assert_kind_of Hash, json['upload']
248
    token = json['upload']['token']
249
    assert token.present?
250
    assert attachment = Attachment.find_by_token(token)
251
    assert_equal 12, attachment.filesize
252
    assert File.exist? attachment.diskfile
253
  end
235 254
end
(2-2/5)