##// END OF EJS Templates
Activity test fix (r1120)....
Jean-Philippe Lang -
r1109:fde2a497da75
parent child
Show More
@@ -1,240 +1,242
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.dirname(__FILE__) + '/../test_helper'
19 19 require 'projects_controller'
20 20
21 21 # Re-raise errors caught by the controller.
22 22 class ProjectsController; def rescue_action(e) raise e end; end
23 23
24 24 class ProjectsControllerTest < Test::Unit::TestCase
25 25 fixtures :projects, :versions, :users, :roles, :members, :issues, :journals, :journal_details, :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations
26 26
27 27 def setup
28 28 @controller = ProjectsController.new
29 29 @request = ActionController::TestRequest.new
30 30 @response = ActionController::TestResponse.new
31 31 end
32 32
33 33 def test_index
34 34 get :index
35 35 assert_response :success
36 36 assert_template 'list'
37 37 end
38 38
39 39 def test_list
40 40 get :list
41 41 assert_response :success
42 42 assert_template 'list'
43 43 assert_not_nil assigns(:project_tree)
44 44 # Root project as hash key
45 45 assert assigns(:project_tree).has_key?(Project.find(1))
46 46 # Subproject in corresponding value
47 47 assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3))
48 48 end
49 49
50 50 def test_show_by_id
51 51 get :show, :id => 1
52 52 assert_response :success
53 53 assert_template 'show'
54 54 assert_not_nil assigns(:project)
55 55 end
56 56
57 57 def test_show_by_identifier
58 58 get :show, :id => 'ecookbook'
59 59 assert_response :success
60 60 assert_template 'show'
61 61 assert_not_nil assigns(:project)
62 62 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
63 63 end
64 64
65 65 def test_settings
66 66 @request.session[:user_id] = 2 # manager
67 67 get :settings, :id => 1
68 68 assert_response :success
69 69 assert_template 'settings'
70 70 end
71 71
72 72 def test_edit
73 73 @request.session[:user_id] = 2 # manager
74 74 post :edit, :id => 1, :project => {:name => 'Test changed name',
75 75 :custom_field_ids => ['']}
76 76 assert_redirected_to 'projects/settings/ecookbook'
77 77 project = Project.find(1)
78 78 assert_equal 'Test changed name', project.name
79 79 end
80 80
81 81 def test_get_destroy
82 82 @request.session[:user_id] = 1 # admin
83 83 get :destroy, :id => 1
84 84 assert_response :success
85 85 assert_template 'destroy'
86 86 assert_not_nil Project.find_by_id(1)
87 87 end
88 88
89 89 def test_post_destroy
90 90 @request.session[:user_id] = 1 # admin
91 91 post :destroy, :id => 1, :confirm => 1
92 92 assert_redirected_to 'admin/projects'
93 93 assert_nil Project.find_by_id(1)
94 94 end
95 95
96 96 def test_bulk_edit_issues
97 97 @request.session[:user_id] = 2
98 98 # update issues priority
99 99 post :bulk_edit_issues, :id => 1, :issue_ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => ''
100 100 assert_response 302
101 101 # check that the issues were updated
102 102 assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
103 103 assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes
104 104 end
105 105
106 106 def test_move_issues_to_another_project
107 107 @request.session[:user_id] = 1
108 108 post :move_issues, :id => 1, :issue_ids => [1, 2], :new_project_id => 2
109 109 assert_redirected_to 'projects/ecookbook/issues'
110 110 assert_equal 2, Issue.find(1).project_id
111 111 assert_equal 2, Issue.find(2).project_id
112 112 end
113 113
114 114 def test_move_issues_to_another_tracker
115 115 @request.session[:user_id] = 1
116 116 post :move_issues, :id => 1, :issue_ids => [1, 2], :new_tracker_id => 2
117 117 assert_redirected_to 'projects/ecookbook/issues'
118 118 assert_equal 2, Issue.find(1).tracker_id
119 119 assert_equal 2, Issue.find(2).tracker_id
120 120 end
121 121
122 122 def test_list_files
123 123 get :list_files, :id => 1
124 124 assert_response :success
125 125 assert_template 'list_files'
126 126 assert_not_nil assigns(:versions)
127 127 end
128 128
129 129 def test_changelog
130 130 get :changelog, :id => 1
131 131 assert_response :success
132 132 assert_template 'changelog'
133 133 assert_not_nil assigns(:versions)
134 134 end
135 135
136 136 def test_roadmap
137 137 get :roadmap, :id => 1
138 138 assert_response :success
139 139 assert_template 'roadmap'
140 140 assert_not_nil assigns(:versions)
141 141 # Version with no date set appears
142 142 assert assigns(:versions).include?(Version.find(3))
143 143 # Completed version doesn't appear
144 144 assert !assigns(:versions).include?(Version.find(1))
145 145 end
146 146
147 147 def test_roadmap_with_completed_versions
148 148 get :roadmap, :id => 1, :completed => 1
149 149 assert_response :success
150 150 assert_template 'roadmap'
151 151 assert_not_nil assigns(:versions)
152 152 # Version with no date set appears
153 153 assert assigns(:versions).include?(Version.find(3))
154 154 # Completed version appears
155 155 assert assigns(:versions).include?(Version.find(1))
156 156 end
157 157
158 158 def test_activity
159 159 get :activity, :id => 1, :year => 2.days.ago.to_date.year, :month => 2.days.ago.to_date.month
160 160 assert_response :success
161 161 assert_template 'activity'
162 162 assert_not_nil assigns(:events_by_day)
163 163
164 164 assert_tag :tag => "h3",
165 165 :content => /#{2.days.ago.to_date.day}/,
166 :sibling => { :tag => "ul",
167 :child => { :tag => "li",
168 :child => { :tag => "p",
166 :sibling => { :tag => "dl",
167 :child => { :tag => "dt",
168 :attributes => { :class => 'journal' },
169 :child => { :tag => "a",
169 170 :content => /(#{IssueStatus.find(2).name})/,
170 171 }
171 172 }
172 173 }
173 174
174 175 get :activity, :id => 1, :year => 3.days.ago.to_date.year, :month => 3.days.ago.to_date.month
175 176 assert_response :success
176 177 assert_template 'activity'
177 178 assert_not_nil assigns(:events_by_day)
178 179
179 180 assert_tag :tag => "h3",
180 181 :content => /#{3.day.ago.to_date.day}/,
181 :sibling => { :tag => "ul",
182 :child => { :tag => "li",
183 :child => { :tag => "p",
182 :sibling => { :tag => "dl",
183 :child => { :tag => "dt",
184 :attributes => { :class => 'issue' },
185 :child => { :tag => "a",
184 186 :content => /#{Issue.find(1).subject}/,
185 187 }
186 188 }
187 189 }
188 190 end
189 191
190 192 def test_calendar
191 193 get :calendar, :id => 1
192 194 assert_response :success
193 195 assert_template 'calendar'
194 196 assert_not_nil assigns(:calendar)
195 197 end
196 198
197 199 def test_calendar_with_subprojects
198 200 get :calendar, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2]
199 201 assert_response :success
200 202 assert_template 'calendar'
201 203 assert_not_nil assigns(:calendar)
202 204 end
203 205
204 206 def test_gantt
205 207 get :gantt, :id => 1
206 208 assert_response :success
207 209 assert_template 'gantt.rhtml'
208 210 assert_not_nil assigns(:events)
209 211 end
210 212
211 213 def test_gantt_with_subprojects
212 214 get :gantt, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2]
213 215 assert_response :success
214 216 assert_template 'gantt.rhtml'
215 217 assert_not_nil assigns(:events)
216 218 end
217 219
218 220 def test_gantt_export_to_pdf
219 221 get :gantt, :id => 1, :format => 'pdf'
220 222 assert_response :success
221 223 assert_template 'gantt.rfpdf'
222 224 assert_equal 'application/pdf', @response.content_type
223 225 assert_not_nil assigns(:events)
224 226 end
225 227
226 228 def test_archive
227 229 @request.session[:user_id] = 1 # admin
228 230 post :archive, :id => 1
229 231 assert_redirected_to 'admin/projects'
230 232 assert !Project.find(1).active?
231 233 end
232 234
233 235 def test_unarchive
234 236 @request.session[:user_id] = 1 # admin
235 237 Project.find(1).archive
236 238 post :unarchive, :id => 1
237 239 assert_redirected_to 'admin/projects'
238 240 assert Project.find(1).active?
239 241 end
240 242 end
General Comments 0
You need to be logged in to leave comments. Login now