summaryrefslogtreecommitdiffstats
path: root/test/integration/api_test/files_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/api_test/files_test.rb')
-rw-r--r--test/integration/api_test/files_test.rb38
1 files changed, 28 insertions, 10 deletions
diff --git a/test/integration/api_test/files_test.rb b/test/integration/api_test/files_test.rb
index caef7f66a..0b355c42c 100644
--- a/test/integration/api_test/files_test.rb
+++ b/test/integration/api_test/files_test.rb
@@ -28,14 +28,16 @@ class Redmine::ApiTest::FilesTest < Redmine::ApiTest::Base
:versions
test "GET /projects/:project_id/files.xml should return the list of uploaded files" do
- get '/projects/1/files.xml', {}, credentials('jsmith')
+ get '/projects/1/files.xml', :headers => credentials('jsmith')
assert_response :success
assert_select 'files>file>id', :text => '8'
end
test "POST /projects/:project_id/files.json should create a file" do
set_tmp_attachments_directory
- post '/uploads.xml', 'File content', {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
+ post '/uploads.xml',
+ :params => 'File content',
+ :headers => {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
token = Attachment.last.token
payload = <<-JSON
{ "file": {
@@ -43,7 +45,9 @@ class Redmine::ApiTest::FilesTest < Redmine::ApiTest::Base
}
}
JSON
- post '/projects/1/files.json', payload, {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))
+ post '/projects/1/files.json',
+ :params => payload,
+ :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
@@ -51,14 +55,18 @@ 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', 'File content', {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
+ post '/uploads.xml',
+ :params => 'File content',
+ :headers => {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
token = Attachment.last.token
payload = <<-XML
<file>
<token>#{token}</token>
</file>
XML
- post '/projects/1/files.xml', payload, {"CONTENT_TYPE" => 'application/xml'}.merge(credentials('jsmith'))
+ post '/projects/1/files.xml',
+ :params => payload,
+ :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
@@ -71,13 +79,17 @@ class Redmine::ApiTest::FilesTest < Redmine::ApiTest::Base
}
}
JSON
- post '/projects/1/files.json', payload, {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))
+ post '/projects/1/files.json',
+ :params => payload,
+ :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', 'File content', {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
+ post '/uploads.xml',
+ :params => 'File content',
+ :headers => {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
token = Attachment.last.token
payload = <<-JSON
{ "file": {
@@ -88,7 +100,9 @@ class Redmine::ApiTest::FilesTest < Redmine::ApiTest::Base
}
}
JSON
- post '/projects/1/files.json', payload, {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))
+ post '/projects/1/files.json',
+ :params => payload,
+ :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
@@ -97,7 +111,9 @@ 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', 'File content', {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
+ post '/uploads.xml',
+ :params => 'File content',
+ :headers => {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
token = Attachment.last.token
payload = <<-JSON
{ "file": {
@@ -108,7 +124,9 @@ class Redmine::ApiTest::FilesTest < Redmine::ApiTest::Base
}
}
JSON
- post '/projects/1/files.json', payload, {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))
+ post '/projects/1/files.json',
+ :params => payload,
+ :headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))
assert_equal 3, Attachment.last.container_id
assert_equal "Version", Attachment.last.container_type
end