ProjectsController#list_issues, #export_issues_csv and #export_issues_pdf merged...
[gitredmine.git] / test / functional / projects_controller_test.rb
blob28f826b8b859c56b815a0bb5a5428d98df69fa1d
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.
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.
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
27   def setup
28     @controller = ProjectsController.new
29     @request    = ActionController::TestRequest.new
30     @response   = ActionController::TestResponse.new
31   end
33   def test_index
34     get :index
35     assert_response :success
36     assert_template 'list'
37   end
39   def test_list
40     get :list
41     assert_response :success
42     assert_template 'list'
43     assert_not_nil assigns(:project_tree)
44   end\r
45   \r
46   def test_show\r
47     get :show, :id => 1\r
48     assert_response :success
49     assert_template 'show'\r
50     assert_not_nil assigns(:project)\r
51   end\r
52   \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
58   end
59   
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 => ''
64     assert_response 302
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
68   end
70   def test_list_news\r
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
75   end\r
77   def test_list_files\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
82   end\r
84   def test_changelog\r
85     get :changelog, :id => 1\r
86     assert_response :success\r
87     assert_template 'changelog'\r
88     assert_not_nil assigns(:versions)\r
89   end
90   
91   def test_roadmap
92     get :roadmap, :id => 1
93     assert_response :success
94     assert_template 'roadmap'
95     assert_not_nil assigns(:versions)
96   end
98   def test_activity
99     get :activity, :id => 1
100     assert_response :success
101     assert_template 'activity'
102     assert_not_nil assigns(:events_by_day)
103   end
104   
105   def test_archive    
106     @request.session[:user_id] = 1 # admin
107     post :archive, :id => 1
108     assert_redirected_to 'admin/projects'
109     assert !Project.find(1).active?
110   end
111   
112   def test_unarchive
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?
118   end
119   
120   def test_add_issue
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')
128   end
129   
130   def test_copy_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)
135     orig = Issue.find(1)
136     assert_equal orig.subject, assigns(:issue).subject
137   end