summaryrefslogtreecommitdiffstats
path: root/test/integration
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-09-16 19:14:44 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-09-16 19:14:44 +0000
commite05e9179fd9ed3646fbf55245089114aab3dcdb6 (patch)
tree6fe31b6c677ecb6bab04658c41c31736dfd87cf6 /test/integration
parentf825167003d61eae25b7eeff4815e8f33e08fedf (diff)
downloadredmine-e05e9179fd9ed3646fbf55245089114aab3dcdb6.tar.gz
redmine-e05e9179fd9ed3646fbf55245089114aab3dcdb6.zip
Added a test for JSON upload.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10407 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/api_test/attachments_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/integration/api_test/attachments_test.rb b/test/integration/api_test/attachments_test.rb
index c19a98ea6..4814c047a 100644
--- a/test/integration/api_test/attachments_test.rb
+++ b/test/integration/api_test/attachments_test.rb
@@ -100,6 +100,23 @@ class ApiTest::AttachmentsTest < ActionController::IntegrationTest
assert_equal 'File content', File.read(attachment.diskfile)
end
+ test "POST /uploads.json should return the token" do
+ set_tmp_attachments_directory
+ assert_difference 'Attachment.count' do
+ post '/uploads.json', 'File content', {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
+ assert_response :created
+ assert_equal 'application/json', response.content_type
+ end
+
+ json = ActiveSupport::JSON.decode(response.body)
+ assert_kind_of Hash, json['upload']
+ token = json['upload']['token']
+ assert_not_nil token
+
+ attachment = Attachment.first(:order => 'id DESC')
+ assert_equal token, attachment.token
+ end
+
test "POST /uploads.xml should not accept other content types" do
set_tmp_attachments_directory
assert_no_difference 'Attachment.count' do