comparison test/integration/api_test/attachments_test.rb @ 1526:404aa68d4227

Merge from live branch
author Chris Cannam
date Thu, 11 Sep 2014 12:46:20 +0100
parents dffacf8a6908
children
comparison
equal deleted inserted replaced
1493:a5f2bdf3b486 1526:404aa68d4227
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
15 # along with this program; if not, write to the Free Software 15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 require File.expand_path('../../../test_helper', __FILE__) 18 require File.expand_path('../../../test_helper', __FILE__)
19 19
20 class ApiTest::AttachmentsTest < ActionController::IntegrationTest 20 class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base
21 fixtures :projects, :trackers, :issue_statuses, :issues, 21 fixtures :projects, :trackers, :issue_statuses, :issues,
22 :enumerations, :users, :issue_categories, 22 :enumerations, :users, :issue_categories,
23 :projects_trackers, 23 :projects_trackers,
24 :roles, 24 :roles,
25 :member_roles, 25 :member_roles,
26 :members, 26 :members,
27 :enabled_modules, 27 :enabled_modules,
28 :workflows,
29 :attachments 28 :attachments
30 29
31 def setup 30 def setup
32 Setting.rest_api_enabled = '1' 31 Setting.rest_api_enabled = '1'
33 set_fixtures_attachments_directory 32 set_fixtures_attachments_directory
86 xml = Hash.from_xml(response.body) 85 xml = Hash.from_xml(response.body)
87 assert_kind_of Hash, xml['upload'] 86 assert_kind_of Hash, xml['upload']
88 token = xml['upload']['token'] 87 token = xml['upload']['token']
89 assert_not_nil token 88 assert_not_nil token
90 89
91 attachment = Attachment.first(:order => 'id DESC') 90 attachment = Attachment.order('id DESC').first
92 assert_equal token, attachment.token 91 assert_equal token, attachment.token
93 assert_nil attachment.container 92 assert_nil attachment.container
94 assert_equal 2, attachment.author_id 93 assert_equal 2, attachment.author_id
95 assert_equal 'File content'.size, attachment.filesize 94 assert_equal 'File content'.size, attachment.filesize
96 assert attachment.content_type.blank? 95 assert attachment.content_type.blank?
111 json = ActiveSupport::JSON.decode(response.body) 110 json = ActiveSupport::JSON.decode(response.body)
112 assert_kind_of Hash, json['upload'] 111 assert_kind_of Hash, json['upload']
113 token = json['upload']['token'] 112 token = json['upload']['token']
114 assert_not_nil token 113 assert_not_nil token
115 114
116 attachment = Attachment.first(:order => 'id DESC') 115 attachment = Attachment.order('id DESC').first
117 assert_equal token, attachment.token 116 assert_equal token, attachment.token
118 end 117 end
119 118
120 test "POST /uploads.xml should accept :filename param as the attachment filename" do 119 test "POST /uploads.xml should accept :filename param as the attachment filename" do
121 set_tmp_attachments_directory 120 set_tmp_attachments_directory