@@ -1,17 +1,17 | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
# |
|
2 | # Redmine - project management software | |
3 |
# Copyright (C) 2006-20 |
|
3 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
4 | # |
|
4 | # | |
5 | # This program is free software; you can redistribute it and/or |
|
5 | # This program is free software; you can redistribute it and/or | |
6 | # modify it under the terms of the GNU General Public License |
|
6 | # modify it under the terms of the GNU General Public License | |
7 | # as published by the Free Software Foundation; either version 2 |
|
7 | # as published by the Free Software Foundation; either version 2 | |
8 | # of the License, or (at your option) any later version. |
|
8 | # of the License, or (at your option) any later version. | |
9 |
# |
|
9 | # | |
10 | # This program is distributed in the hope that it will be useful, |
|
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. |
|
13 | # GNU General Public License for more details. | |
14 |
# |
|
14 | # | |
15 | # You should have received a copy of the GNU General Public License |
|
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program; if not, write to the Free Software |
|
16 | # along with this program; if not, write to the Free Software | |
17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
@@ -30,7 +30,7 class TimelogControllerTest < ActionController::TestCase | |||||
30 | @request = ActionController::TestRequest.new |
|
30 | @request = ActionController::TestRequest.new | |
31 | @response = ActionController::TestResponse.new |
|
31 | @response = ActionController::TestResponse.new | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
34 | def test_get_new |
|
34 | def test_get_new | |
35 | @request.session[:user_id] = 3 |
|
35 | @request.session[:user_id] = 3 | |
36 | get :new, :project_id => 1 |
|
36 | get :new, :project_id => 1 | |
@@ -40,14 +40,13 class TimelogControllerTest < ActionController::TestCase | |||||
40 | assert_tag :tag => 'option', :attributes => { :selected => 'selected' }, |
|
40 | assert_tag :tag => 'option', :attributes => { :selected => 'selected' }, | |
41 | :content => 'Development' |
|
41 | :content => 'Development' | |
42 | end |
|
42 | end | |
43 |
|
43 | |||
44 | def test_get_new_should_only_show_active_time_entry_activities |
|
44 | def test_get_new_should_only_show_active_time_entry_activities | |
45 | @request.session[:user_id] = 3 |
|
45 | @request.session[:user_id] = 3 | |
46 | get :new, :project_id => 1 |
|
46 | get :new, :project_id => 1 | |
47 | assert_response :success |
|
47 | assert_response :success | |
48 | assert_template 'edit' |
|
48 | assert_template 'edit' | |
49 | assert_no_tag :tag => 'option', :content => 'Inactive Activity' |
|
49 | assert_no_tag :tag => 'option', :content => 'Inactive Activity' | |
50 |
|
||||
51 | end |
|
50 | end | |
52 |
|
51 | |||
53 | def test_get_edit_existing_time |
|
52 | def test_get_edit_existing_time | |
@@ -58,7 +57,7 class TimelogControllerTest < ActionController::TestCase | |||||
58 | # Default activity selected |
|
57 | # Default activity selected | |
59 | assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/time_entries/2' } |
|
58 | assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/time_entries/2' } | |
60 | end |
|
59 | end | |
61 |
|
60 | |||
62 | def test_get_edit_with_an_existing_time_entry_with_inactive_activity |
|
61 | def test_get_edit_with_an_existing_time_entry_with_inactive_activity | |
63 | te = TimeEntry.find(1) |
|
62 | te = TimeEntry.find(1) | |
64 | te.activity = TimeEntryActivity.find_by_name("Inactive Activity") |
|
63 | te.activity = TimeEntryActivity.find_by_name("Inactive Activity") | |
@@ -71,7 +70,7 class TimelogControllerTest < ActionController::TestCase | |||||
71 | # Blank option since nothing is pre-selected |
|
70 | # Blank option since nothing is pre-selected | |
72 | assert_tag :tag => 'option', :content => '--- Please select ---' |
|
71 | assert_tag :tag => 'option', :content => '--- Please select ---' | |
73 | end |
|
72 | end | |
74 |
|
73 | |||
75 | def test_post_create |
|
74 | def test_post_create | |
76 | # TODO: should POST to issuesβ time log instead of project. change form |
|
75 | # TODO: should POST to issuesβ time log instead of project. change form | |
77 | # and routing |
|
76 | # and routing | |
@@ -84,7 +83,7 class TimelogControllerTest < ActionController::TestCase | |||||
84 | :issue_id => '1', |
|
83 | :issue_id => '1', | |
85 | :hours => '7.3'} |
|
84 | :hours => '7.3'} | |
86 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
85 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |
87 |
|
86 | |||
88 | i = Issue.find(1) |
|
87 | i = Issue.find(1) | |
89 | t = TimeEntry.find_by_comments('Some work on TimelogControllerTest') |
|
88 | t = TimeEntry.find_by_comments('Some work on TimelogControllerTest') | |
90 | assert_not_nil t |
|
89 | assert_not_nil t | |
@@ -107,26 +106,26 class TimelogControllerTest < ActionController::TestCase | |||||
107 | :spent_on => '2008-03-14', |
|
106 | :spent_on => '2008-03-14', | |
108 | :hours => '7.3'} |
|
107 | :hours => '7.3'} | |
109 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
108 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |
110 |
|
109 | |||
111 | t = TimeEntry.find_by_comments('Some work on TimelogControllerTest') |
|
110 | t = TimeEntry.find_by_comments('Some work on TimelogControllerTest') | |
112 | assert_not_nil t |
|
111 | assert_not_nil t | |
113 | assert_equal 11, t.activity_id |
|
112 | assert_equal 11, t.activity_id | |
114 | assert_equal 7.3, t.hours |
|
113 | assert_equal 7.3, t.hours | |
115 | assert_equal 3, t.user_id |
|
114 | assert_equal 3, t.user_id | |
116 | end |
|
115 | end | |
117 |
|
116 | |||
118 | def test_update |
|
117 | def test_update | |
119 | entry = TimeEntry.find(1) |
|
118 | entry = TimeEntry.find(1) | |
120 | assert_equal 1, entry.issue_id |
|
119 | assert_equal 1, entry.issue_id | |
121 | assert_equal 2, entry.user_id |
|
120 | assert_equal 2, entry.user_id | |
122 |
|
121 | |||
123 | @request.session[:user_id] = 1 |
|
122 | @request.session[:user_id] = 1 | |
124 | put :update, :id => 1, |
|
123 | put :update, :id => 1, | |
125 | :time_entry => {:issue_id => '2', |
|
124 | :time_entry => {:issue_id => '2', | |
126 | :hours => '8'} |
|
125 | :hours => '8'} | |
127 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
126 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |
128 | entry.reload |
|
127 | entry.reload | |
129 |
|
128 | |||
130 | assert_equal 8, entry.hours |
|
129 | assert_equal 8, entry.hours | |
131 | assert_equal 2, entry.issue_id |
|
130 | assert_equal 2, entry.issue_id | |
132 | assert_equal 2, entry.user_id |
|
131 | assert_equal 2, entry.user_id | |
@@ -137,7 +136,7 class TimelogControllerTest < ActionController::TestCase | |||||
137 | get :bulk_edit, :ids => [1, 2] |
|
136 | get :bulk_edit, :ids => [1, 2] | |
138 | assert_response :success |
|
137 | assert_response :success | |
139 | assert_template 'bulk_edit' |
|
138 | assert_template 'bulk_edit' | |
140 |
|
139 | |||
141 | # System wide custom field |
|
140 | # System wide custom field | |
142 | assert_tag :select, :attributes => {:name => 'time_entry[custom_field_values][10]'} |
|
141 | assert_tag :select, :attributes => {:name => 'time_entry[custom_field_values][10]'} | |
143 | end |
|
142 | end | |
@@ -153,7 +152,7 class TimelogControllerTest < ActionController::TestCase | |||||
153 | @request.session[:user_id] = 2 |
|
152 | @request.session[:user_id] = 2 | |
154 | # update time entry activity |
|
153 | # update time entry activity | |
155 | post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9} |
|
154 | post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9} | |
156 |
|
155 | |||
157 | assert_response 302 |
|
156 | assert_response 302 | |
158 | # check that the issues were updated |
|
157 | # check that the issues were updated | |
159 | assert_equal [9, 9], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.activity_id} |
|
158 | assert_equal [9, 9], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.activity_id} | |
@@ -163,7 +162,7 class TimelogControllerTest < ActionController::TestCase | |||||
163 | @request.session[:user_id] = 2 |
|
162 | @request.session[:user_id] = 2 | |
164 | # update time entry activity |
|
163 | # update time entry activity | |
165 | post :bulk_update, :ids => [1, 2, 4], :time_entry => { :activity_id => 9 } |
|
164 | post :bulk_update, :ids => [1, 2, 4], :time_entry => { :activity_id => 9 } | |
166 |
|
165 | |||
167 | assert_response 302 |
|
166 | assert_response 302 | |
168 | # check that the issues were updated |
|
167 | # check that the issues were updated | |
169 | assert_equal [9, 9, 9], TimeEntry.find_all_by_id([1, 2, 4]).collect {|i| i.activity_id} |
|
168 | assert_equal [9, 9, 9], TimeEntry.find_all_by_id([1, 2, 4]).collect {|i| i.activity_id} | |
@@ -182,7 +181,7 class TimelogControllerTest < ActionController::TestCase | |||||
182 | def test_bulk_update_custom_field |
|
181 | def test_bulk_update_custom_field | |
183 | @request.session[:user_id] = 2 |
|
182 | @request.session[:user_id] = 2 | |
184 | post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} } |
|
183 | post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} } | |
185 |
|
184 | |||
186 | assert_response 302 |
|
185 | assert_response 302 | |
187 | assert_equal ["0", "0"], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.custom_value_for(10).value} |
|
186 | assert_equal ["0", "0"], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.custom_value_for(10).value} | |
188 | end |
|
187 | end | |
@@ -202,7 +201,7 class TimelogControllerTest < ActionController::TestCase | |||||
202 | assert_response :redirect |
|
201 | assert_response :redirect | |
203 | assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => Project.find(1).identifier |
|
202 | assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => Project.find(1).identifier | |
204 | end |
|
203 | end | |
205 |
|
204 | |||
206 | def test_destroy |
|
205 | def test_destroy | |
207 | @request.session[:user_id] = 2 |
|
206 | @request.session[:user_id] = 2 | |
208 | delete :destroy, :id => 1 |
|
207 | delete :destroy, :id => 1 | |
@@ -210,7 +209,7 class TimelogControllerTest < ActionController::TestCase | |||||
210 | assert_equal I18n.t(:notice_successful_delete), flash[:notice] |
|
209 | assert_equal I18n.t(:notice_successful_delete), flash[:notice] | |
211 | assert_nil TimeEntry.find_by_id(1) |
|
210 | assert_nil TimeEntry.find_by_id(1) | |
212 | end |
|
211 | end | |
213 |
|
212 | |||
214 | def test_destroy_should_fail |
|
213 | def test_destroy_should_fail | |
215 | # simulate that this fails (e.g. due to a plugin), see #5700 |
|
214 | # simulate that this fails (e.g. due to a plugin), see #5700 | |
216 | TimeEntry.any_instance.expects(:destroy).returns(false) |
|
215 | TimeEntry.any_instance.expects(:destroy).returns(false) | |
@@ -221,7 +220,7 class TimelogControllerTest < ActionController::TestCase | |||||
221 | assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error] |
|
220 | assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error] | |
222 | assert_not_nil TimeEntry.find_by_id(1) |
|
221 | assert_not_nil TimeEntry.find_by_id(1) | |
223 | end |
|
222 | end | |
224 |
|
223 | |||
225 | def test_index_all_projects |
|
224 | def test_index_all_projects | |
226 | get :index |
|
225 | get :index | |
227 | assert_response :success |
|
226 | assert_response :success | |
@@ -231,7 +230,7 class TimelogControllerTest < ActionController::TestCase | |||||
231 | assert_tag :form, |
|
230 | assert_tag :form, | |
232 | :attributes => {:action => "/time_entries", :id => 'query_form'} |
|
231 | :attributes => {:action => "/time_entries", :id => 'query_form'} | |
233 | end |
|
232 | end | |
234 |
|
233 | |||
235 | def test_index_at_project_level |
|
234 | def test_index_at_project_level | |
236 | get :index, :project_id => 'ecookbook' |
|
235 | get :index, :project_id => 'ecookbook' | |
237 | assert_response :success |
|
236 | assert_response :success | |
@@ -248,7 +247,7 class TimelogControllerTest < ActionController::TestCase | |||||
248 | assert_tag :form, |
|
247 | assert_tag :form, | |
249 | :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'} |
|
248 | :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'} | |
250 | end |
|
249 | end | |
251 |
|
250 | |||
252 | def test_index_at_project_level_with_date_range |
|
251 | def test_index_at_project_level_with_date_range | |
253 | get :index, :project_id => 'ecookbook', :from => '2007-03-20', :to => '2007-04-30' |
|
252 | get :index, :project_id => 'ecookbook', :from => '2007-03-20', :to => '2007-04-30' | |
254 | assert_response :success |
|
253 | assert_response :success | |
@@ -284,7 +283,7 class TimelogControllerTest < ActionController::TestCase | |||||
284 | assert_tag :form, |
|
283 | assert_tag :form, | |
285 | :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'} |
|
284 | :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'} | |
286 | end |
|
285 | end | |
287 |
|
286 | |||
288 | def test_index_at_issue_level |
|
287 | def test_index_at_issue_level | |
289 | get :index, :issue_id => 1 |
|
288 | get :index, :issue_id => 1 | |
290 | assert_response :success |
|
289 | assert_response :success | |
@@ -301,7 +300,7 class TimelogControllerTest < ActionController::TestCase | |||||
301 | assert_tag :form, |
|
300 | assert_tag :form, | |
302 | :attributes => {:action => "/projects/ecookbook/issues/1/time_entries", :id => 'query_form'} |
|
301 | :attributes => {:action => "/projects/ecookbook/issues/1/time_entries", :id => 'query_form'} | |
303 | end |
|
302 | end | |
304 |
|
303 | |||
305 | def test_index_atom_feed |
|
304 | def test_index_atom_feed | |
306 | get :index, :project_id => 1, :format => 'atom' |
|
305 | get :index, :project_id => 1, :format => 'atom' | |
307 | assert_response :success |
|
306 | assert_response :success | |
@@ -309,7 +308,7 class TimelogControllerTest < ActionController::TestCase | |||||
309 | assert_not_nil assigns(:items) |
|
308 | assert_not_nil assigns(:items) | |
310 | assert assigns(:items).first.is_a?(TimeEntry) |
|
309 | assert assigns(:items).first.is_a?(TimeEntry) | |
311 | end |
|
310 | end | |
312 |
|
311 | |||
313 | def test_index_all_projects_csv_export |
|
312 | def test_index_all_projects_csv_export | |
314 | Setting.date_format = '%m/%d/%Y' |
|
313 | Setting.date_format = '%m/%d/%Y' | |
315 | get :index, :format => 'csv' |
|
314 | get :index, :format => 'csv' | |
@@ -318,7 +317,7 class TimelogControllerTest < ActionController::TestCase | |||||
318 | assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n") |
|
317 | assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n") | |
319 | assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n") |
|
318 | assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n") | |
320 | end |
|
319 | end | |
321 |
|
320 | |||
322 | def test_index_csv_export |
|
321 | def test_index_csv_export | |
323 | Setting.date_format = '%m/%d/%Y' |
|
322 | Setting.date_format = '%m/%d/%Y' | |
324 | get :index, :project_id => 1, :format => 'csv' |
|
323 | get :index, :project_id => 1, :format => 'csv' |
General Comments 0
You need to be logged in to leave comments.
Login now