1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
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.
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.
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.
18 require File.dirname(__FILE__) + '/../test_helper'
19 require 'projects_controller'
21 # Re-raise errors caught by the controller.
22 class ProjectsController; def rescue_action(e) raise e end; end
24 class ProjectsControllerTest < Test::Unit::TestCase
25 fixtures :projects, :users, :roles, :members, :issues, :enabled_modules, :enumerations
28 @controller = ProjectsController.new
29 @request = ActionController::TestRequest.new
30 @response = ActionController::TestResponse.new
35 assert_response :success
36 assert_template 'list'
41 assert_response :success
42 assert_template 'list'
43 assert_not_nil assigns(:project_tree)
48 assert_response :success
49 assert_template 'show'
\r
50 assert_not_nil assigns(:project)
\r
53 def test_list_documents
\r
54 get :list_documents, :id => 1
\r
55 assert_response :success
56 assert_template 'list_documents'
\r
57 assert_not_nil assigns(:grouped)
\r
60 def test_bulk_edit_issues
61 @request.session[:user_id] = 2
62 # update issues priority
63 post :bulk_edit_issues, :id => 1, :issue_ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => ''
65 # check that the issues were updated
66 assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
67 assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes
71 get :list_news, :id => 1
\r
72 assert_response :success
\r
73 assert_template 'list_news'
\r
74 assert_not_nil assigns(:newss)
\r
78 get :list_files, :id => 1
\r
79 assert_response :success
\r
80 assert_template 'list_files'
\r
81 assert_not_nil assigns(:versions)
\r
85 get :changelog, :id => 1
\r
86 assert_response :success
\r
87 assert_template 'changelog'
\r
88 assert_not_nil assigns(:versions)
\r
92 get :roadmap, :id => 1
93 assert_response :success
94 assert_template 'roadmap'
95 assert_not_nil assigns(:versions)
99 get :activity, :id => 1
100 assert_response :success
101 assert_template 'activity'
102 assert_not_nil assigns(:events_by_day)
106 @request.session[:user_id] = 1 # admin
107 post :archive, :id => 1
108 assert_redirected_to 'admin/projects'
109 assert !Project.find(1).active?
113 @request.session[:user_id] = 1 # admin
114 Project.find(1).archive
115 post :unarchive, :id => 1
116 assert_redirected_to 'admin/projects'
117 assert Project.find(1).active?
121 @request.session[:user_id] = 2
122 get :add_issue, :id => 1, :tracker_id => 1
123 assert_response :success
124 assert_template 'add_issue'
125 post :add_issue, :id => 1, :issue => {:tracker_id => 1, :subject => 'This is the test_add_issue issue', :description => 'This is the description', :priority_id => 5}
126 assert_redirected_to 'projects/1/issues'
127 assert Issue.find_by_subject('This is the test_add_issue issue')
131 @request.session[:user_id] = 2
132 get :add_issue, :id => 1, :copy_from => 1
133 assert_template 'add_issue'
134 assert_not_nil assigns(:issue)
136 assert_equal orig.subject, assigns(:issue).subject