Mercurial > hg > soundsoftware-site
comparison test/functional/files_controller_test.rb @ 1295:622f24f53b42 redmine-2.3
Update to Redmine SVN revision 11972 on 2.3-stable branch
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:02:21 +0100 |
parents | 433d4f72a19b |
children | e248c7af89ec |
comparison
equal
deleted
inserted
replaced
1294:3e4c3460b6ca | 1295:622f24f53b42 |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2013 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
14 # You should have received a copy of the GNU General Public License | |
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. | |
17 | |
1 require File.expand_path('../../test_helper', __FILE__) | 18 require File.expand_path('../../test_helper', __FILE__) |
2 | 19 |
3 class FilesControllerTest < ActionController::TestCase | 20 class FilesControllerTest < ActionController::TestCase |
4 fixtures :projects, :trackers, :issue_statuses, :issues, | 21 fixtures :projects, :trackers, :issue_statuses, :issues, |
5 :enumerations, :users, :issue_categories, | 22 :enumerations, :users, :issue_categories, |
6 :projects_trackers, | 23 :projects_trackers, |
7 :roles, | 24 :roles, |
8 :member_roles, | 25 :member_roles, |
9 :members, | 26 :members, |
10 :enabled_modules, | 27 :enabled_modules, |
11 :workflows, | |
12 :journals, :journal_details, | 28 :journals, :journal_details, |
13 :attachments, | 29 :attachments, |
14 :versions | 30 :versions |
15 | 31 |
16 def setup | 32 def setup |
17 @controller = FilesController.new | |
18 @request = ActionController::TestRequest.new | |
19 @response = ActionController::TestResponse.new | |
20 @request.session[:user_id] = nil | 33 @request.session[:user_id] = nil |
21 Setting.default_language = 'en' | 34 Setting.default_language = 'en' |
22 end | 35 end |
23 | 36 |
24 def test_index | 37 def test_index |
66 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | 79 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} |
67 assert_response :redirect | 80 assert_response :redirect |
68 end | 81 end |
69 end | 82 end |
70 assert_redirected_to '/projects/ecookbook/files' | 83 assert_redirected_to '/projects/ecookbook/files' |
71 a = Attachment.find(:first, :order => 'created_on DESC') | 84 a = Attachment.order('created_on DESC').first |
72 assert_equal 'testfile.txt', a.filename | 85 assert_equal 'testfile.txt', a.filename |
73 assert_equal Project.find(1), a.container | 86 assert_equal Project.find(1), a.container |
74 | 87 |
75 mail = ActionMailer::Base.deliveries.last | 88 mail = ActionMailer::Base.deliveries.last |
76 assert_not_nil mail | 89 assert_not_nil mail |
86 post :create, :project_id => 1, :version_id => '2', | 99 post :create, :project_id => 1, :version_id => '2', |
87 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | 100 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} |
88 assert_response :redirect | 101 assert_response :redirect |
89 end | 102 end |
90 assert_redirected_to '/projects/ecookbook/files' | 103 assert_redirected_to '/projects/ecookbook/files' |
91 a = Attachment.find(:first, :order => 'created_on DESC') | 104 a = Attachment.order('created_on DESC').first |
92 assert_equal 'testfile.txt', a.filename | 105 assert_equal 'testfile.txt', a.filename |
93 assert_equal Version.find(2), a.container | 106 assert_equal Version.find(2), a.container |
94 end | 107 end |
95 | 108 |
96 end | 109 end |