@@ -129,3 +129,17 custom_fields_009: | |||
|
129 | 129 | field_format: date |
|
130 | 130 | default_value: "" |
|
131 | 131 | editable: true |
|
132 | custom_fields_010: | |
|
133 | name: Overtime | |
|
134 | min_length: 0 | |
|
135 | regexp: "" | |
|
136 | is_for_all: false | |
|
137 | is_filter: false | |
|
138 | type: TimeEntryCustomField | |
|
139 | max_length: 0 | |
|
140 | possible_values: "" | |
|
141 | id: 10 | |
|
142 | is_required: false | |
|
143 | field_format: bool | |
|
144 | default_value: 0 | |
|
145 | editable: true |
@@ -55,4 +55,18 time_entries_004: | |||
|
55 | 55 | hours: 7.65 |
|
56 | 56 | user_id: 1 |
|
57 | 57 | tyear: 2007 |
|
58 | time_entries_005: | |
|
59 | created_on: 2011-03-22 12:20:48 +02:00 | |
|
60 | tweek: 12 | |
|
61 | tmonth: 3 | |
|
62 | project_id: 5 | |
|
63 | comments: Time spent on a subproject | |
|
64 | updated_on: 2011-03-22 12:20:48 +02:00 | |
|
65 | activity_id: 10 | |
|
66 | spent_on: 2011-03-22 | |
|
67 | issue_id: | |
|
68 | id: 5 | |
|
69 | hours: 7.65 | |
|
70 | user_id: 1 | |
|
71 | tyear: 2011 | |
|
58 | 72 |
@@ -132,6 +132,77 class TimelogControllerTest < ActionController::TestCase | |||
|
132 | 132 | assert_equal 2, entry.user_id |
|
133 | 133 | end |
|
134 | 134 | |
|
135 | def test_get_bulk_edit | |
|
136 | @request.session[:user_id] = 2 | |
|
137 | get :bulk_edit, :ids => [1, 2] | |
|
138 | assert_response :success | |
|
139 | assert_template 'bulk_edit' | |
|
140 | ||
|
141 | # System wide custom field | |
|
142 | assert_tag :select, :attributes => {:name => 'time_entry[custom_field_values][10]'} | |
|
143 | end | |
|
144 | ||
|
145 | def test_get_bulk_edit_on_different_projects | |
|
146 | @request.session[:user_id] = 2 | |
|
147 | get :bulk_edit, :ids => [1, 2, 6] | |
|
148 | assert_response :success | |
|
149 | assert_template 'bulk_edit' | |
|
150 | end | |
|
151 | ||
|
152 | def test_bulk_update | |
|
153 | @request.session[:user_id] = 2 | |
|
154 | # update time entry activity | |
|
155 | post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9} | |
|
156 | ||
|
157 | assert_response 302 | |
|
158 | # check that the issues were updated | |
|
159 | assert_equal [9, 9], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.activity_id} | |
|
160 | end | |
|
161 | ||
|
162 | def test_bulk_update_on_different_projects | |
|
163 | @request.session[:user_id] = 2 | |
|
164 | # update time entry activity | |
|
165 | post :bulk_update, :ids => [1, 2, 4], :time_entry => { :activity_id => 9 } | |
|
166 | ||
|
167 | assert_response 302 | |
|
168 | # 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} | |
|
170 | end | |
|
171 | ||
|
172 | def test_bulk_update_on_different_projects_without_rights | |
|
173 | @request.session[:user_id] = 3 | |
|
174 | user = User.find(3) | |
|
175 | action = { :controller => "timelog", :action => "bulk_update" } | |
|
176 | assert user.allowed_to?(action, TimeEntry.find(1).project) | |
|
177 | assert ! user.allowed_to?(action, TimeEntry.find(5).project) | |
|
178 | post :bulk_update, :ids => [1, 5], :time_entry => { :activity_id => 9 } | |
|
179 | assert_response 403 | |
|
180 | end | |
|
181 | ||
|
182 | def test_bulk_update_custom_field | |
|
183 | @request.session[:user_id] = 2 | |
|
184 | post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} } | |
|
185 | ||
|
186 | assert_response 302 | |
|
187 | assert_equal ["0", "0"], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.custom_value_for(10).value} | |
|
188 | end | |
|
189 | ||
|
190 | def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter | |
|
191 | @request.session[:user_id] = 2 | |
|
192 | post :bulk_update, :ids => [1,2], :back_url => '/time_entries' | |
|
193 | ||
|
194 | assert_response :redirect | |
|
195 | assert_redirected_to '/time_entries' | |
|
196 | end | |
|
197 | ||
|
198 | def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host | |
|
199 | @request.session[:user_id] = 2 | |
|
200 | post :bulk_update, :ids => [1,2], :back_url => 'http://google.com' | |
|
201 | ||
|
202 | assert_response :redirect | |
|
203 | assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => Project.find(1).identifier | |
|
204 | end | |
|
205 | ||
|
135 | 206 | def test_destroy |
|
136 | 207 | @request.session[:user_id] = 2 |
|
137 | 208 | delete :destroy, :id => 1 |
@@ -250,8 +321,8 class TimelogControllerTest < ActionController::TestCase | |||
|
250 | 321 | get :index, :format => 'csv' |
|
251 | 322 | assert_response :success |
|
252 | 323 | assert_equal 'text/csv', @response.content_type |
|
253 | assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n") | |
|
254 | assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\"\n") | |
|
324 | assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n") | |
|
325 | assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n") | |
|
255 | 326 | end |
|
256 | 327 | |
|
257 | 328 | def test_index_csv_export |
@@ -259,7 +330,7 class TimelogControllerTest < ActionController::TestCase | |||
|
259 | 330 | get :index, :project_id => 1, :format => 'csv' |
|
260 | 331 | assert_response :success |
|
261 | 332 | assert_equal 'text/csv', @response.content_type |
|
262 | assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n") | |
|
263 | assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\"\n") | |
|
333 | assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n") | |
|
334 | assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n") | |
|
264 | 335 | end |
|
265 | 336 | end |
@@ -26,7 +26,7 class TimeEntryActivityTest < ActiveSupport::TestCase | |||
|
26 | 26 | |
|
27 | 27 | def test_objects_count |
|
28 | 28 | assert_equal 3, TimeEntryActivity.find_by_name("Design").objects_count |
|
29 |
assert_equal |
|
|
29 | assert_equal 2, TimeEntryActivity.find_by_name("Development").objects_count | |
|
30 | 30 | end |
|
31 | 31 | |
|
32 | 32 | def test_option_name |
General Comments 0
You need to be logged in to leave comments.
Login now