diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-12-22 13:41:51 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-12-22 13:41:51 +0000 |
commit | 9b082712a09146b4237cf3427dce6293ba748643 (patch) | |
tree | fc3080139f07ff6d9881ea469420d6871ed8b636 /test/integration | |
parent | 6c6ea394af66e2dcf41ce5c16526d93da1c29507 (diff) | |
download | redmine-9b082712a09146b4237cf3427dce6293ba748643.tar.gz redmine-9b082712a09146b4237cf3427dce6293ba748643.zip |
Adds tests for creating an issue with multiple uploads.
git-svn-id: http://svn.redmine.org/redmine/trunk@13791 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/integration')
-rw-r--r-- | test/integration/api_test/issues_test.rb | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/integration/api_test/issues_test.rb b/test/integration/api_test/issues_test.rb index 161beee67..439e1d400 100644 --- a/test/integration/api_test/issues_test.rb +++ b/test/integration/api_test/issues_test.rb @@ -561,6 +561,63 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base assert_response :success end + def test_create_issue_with_multiple_uploaded_files_as_xml + token1 = xml_upload('File content 1', credentials('jsmith')) + token2 = xml_upload('File content 2', credentials('jsmith')) + + payload = <<-XML +<?xml version="1.0" encoding="UTF-8" ?> +<issue> + <project_id>1</project_id> + <tracker_id>1</tracker_id> + <subject>Issue with multiple attachments</subject> + <uploads type="array"> + <upload> + <token>#{token1}</token> + <filename>test1.txt</filename> + </upload> + <upload> + <token>#{token2}</token> + <filename>test1.txt</filename> + </upload> + </uploads> +</issue> +XML + + assert_difference 'Issue.count' do + post '/issues.xml', payload, {"CONTENT_TYPE" => 'application/xml'}.merge(credentials('jsmith')) + assert_response :created + end + issue = Issue.order('id DESC').first + assert_equal 2, issue.attachments.count + end + + def test_create_issue_with_multiple_uploaded_files_as_json + token1 = json_upload('File content 1', credentials('jsmith')) + token2 = json_upload('File content 2', credentials('jsmith')) + + payload = <<-JSON +{ + "issue": { + "project_id": "1", + "tracker_id": "1", + "subject": "Issue with multiple attachments", + "uploads": [ + {"token": "#{token1}", "filename": "test1.txt"}, + {"token": "#{token2}", "filename": "test2.txt"} + ] + } +} +JSON + + assert_difference 'Issue.count' do + post '/issues.json', payload, {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith')) + assert_response :created + end + issue = Issue.order('id DESC').first + assert_equal 2, issue.attachments.count + end + def test_update_issue_with_uploaded_file set_tmp_attachments_directory # upload the file |