Redmine 4.1.1
This commit is contained in:
parent
33e7b881a5
commit
3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -35,19 +37,21 @@ class Redmine::ApiTest::FilesTest < Redmine::ApiTest::Base
|
|||
|
||||
test "POST /projects/:project_id/files.json should create a file" do
|
||||
set_tmp_attachments_directory
|
||||
post '/uploads.xml',
|
||||
post(
|
||||
'/uploads.xml',
|
||||
:params => 'File content',
|
||||
:headers => {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
|
||||
:headers => {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith')))
|
||||
token = Attachment.last.token
|
||||
payload = <<-JSON
|
||||
{ "file": {
|
||||
"token": "#{token}"
|
||||
}
|
||||
}
|
||||
payload = <<~JSON
|
||||
{ "file": {
|
||||
"token": "#{token}"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
post '/projects/1/files.json',
|
||||
post(
|
||||
'/projects/1/files.json',
|
||||
:params => payload,
|
||||
:headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))
|
||||
:headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith')))
|
||||
assert_response :success
|
||||
assert_equal 1, Attachment.last.container_id
|
||||
assert_equal "Project", Attachment.last.container_type
|
||||
|
@ -55,54 +59,59 @@ class Redmine::ApiTest::FilesTest < Redmine::ApiTest::Base
|
|||
|
||||
test "POST /projects/:project_id/files.xml should create a file" do
|
||||
set_tmp_attachments_directory
|
||||
post '/uploads.xml',
|
||||
post(
|
||||
'/uploads.xml',
|
||||
:params => 'File content',
|
||||
:headers => {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
|
||||
:headers => {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith')))
|
||||
token = Attachment.last.token
|
||||
payload = <<-XML
|
||||
<file>
|
||||
<token>#{token}</token>
|
||||
</file>
|
||||
payload = <<~XML
|
||||
<file>
|
||||
<token>#{token}</token>
|
||||
</file>
|
||||
XML
|
||||
post '/projects/1/files.xml',
|
||||
post(
|
||||
'/projects/1/files.xml',
|
||||
:params => payload,
|
||||
:headers => {"CONTENT_TYPE" => 'application/xml'}.merge(credentials('jsmith'))
|
||||
:headers => {"CONTENT_TYPE" => 'application/xml'}.merge(credentials('jsmith')))
|
||||
assert_response :success
|
||||
assert_equal 1, Attachment.last.container_id
|
||||
assert_equal "Project", Attachment.last.container_type
|
||||
end
|
||||
|
||||
test "POST /projects/:project_id/files.json should refuse requests without the :token parameter" do
|
||||
payload = <<-JSON
|
||||
{ "file": {
|
||||
"filename": "project_file.zip",
|
||||
}
|
||||
}
|
||||
payload = <<~JSON
|
||||
{ "file": {
|
||||
"filename": "project_file.zip",
|
||||
}
|
||||
}
|
||||
JSON
|
||||
post '/projects/1/files.json',
|
||||
post(
|
||||
'/projects/1/files.json',
|
||||
:params => payload,
|
||||
:headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))
|
||||
:headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith')))
|
||||
assert_response :bad_request
|
||||
end
|
||||
|
||||
test "POST /projects/:project_id/files.json should accept :filename, :description, :content_type as optional parameters" do
|
||||
set_tmp_attachments_directory
|
||||
post '/uploads.xml',
|
||||
post(
|
||||
'/uploads.xml',
|
||||
:params => 'File content',
|
||||
:headers => {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
|
||||
:headers => {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith')))
|
||||
token = Attachment.last.token
|
||||
payload = <<-JSON
|
||||
{ "file": {
|
||||
"filename": "New filename",
|
||||
"description": "New description",
|
||||
"content_type": "application/txt",
|
||||
"token": "#{token}"
|
||||
}
|
||||
}
|
||||
payload = <<~JSON
|
||||
{ "file": {
|
||||
"filename": "New filename",
|
||||
"description": "New description",
|
||||
"content_type": "application/txt",
|
||||
"token": "#{token}"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
post '/projects/1/files.json',
|
||||
post(
|
||||
'/projects/1/files.json',
|
||||
:params => payload,
|
||||
:headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))
|
||||
:headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith')))
|
||||
assert_response :success
|
||||
assert_equal "New filename", Attachment.last.filename
|
||||
assert_equal "New description", Attachment.last.description
|
||||
|
@ -111,22 +120,24 @@ class Redmine::ApiTest::FilesTest < Redmine::ApiTest::Base
|
|||
|
||||
test "POST /projects/:project_id/files.json should accept :version_id to attach the files to a version" do
|
||||
set_tmp_attachments_directory
|
||||
post '/uploads.xml',
|
||||
post(
|
||||
'/uploads.xml',
|
||||
:params => 'File content',
|
||||
:headers => {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
|
||||
:headers => {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith')))
|
||||
token = Attachment.last.token
|
||||
payload = <<-JSON
|
||||
{ "file": {
|
||||
"version_id": 3,
|
||||
"filename": "New filename",
|
||||
"description": "New description",
|
||||
"token": "#{token}"
|
||||
}
|
||||
}
|
||||
payload = <<~JSON
|
||||
{ "file": {
|
||||
"version_id": 3,
|
||||
"filename": "New filename",
|
||||
"description": "New description",
|
||||
"token": "#{token}"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
post '/projects/1/files.json',
|
||||
post(
|
||||
'/projects/1/files.json',
|
||||
:params => payload,
|
||||
:headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))
|
||||
:headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith')))
|
||||
assert_equal 3, Attachment.last.container_id
|
||||
assert_equal "Version", Attachment.last.container_type
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue