##// END OF EJS Templates
Merged r15532 to r15534 (#23054)....
Jean-Philippe Lang -
r15155:89cfe130fc04
parent child
Show More
@@ -352,6 +352,22 class ApplicationController < ActionController::Base
352 @attachments = att || []
352 @attachments = att || []
353 end
353 end
354
354
355 def parse_params_for_bulk_update(params)
356 attributes = (params || {}).reject {|k,v| v.blank?}
357 attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
358 if custom = attributes[:custom_field_values]
359 custom.reject! {|k,v| v.blank?}
360 custom.keys.each do |k|
361 if custom[k].is_a?(Array)
362 custom[k] << '' if custom[k].delete('__none__')
363 else
364 custom[k] = '' if custom[k] == '__none__'
365 end
366 end
367 end
368 attributes
369 end
370
355 # make sure that the user is a member of the project (or admin) if project is private
371 # make sure that the user is a member of the project (or admin) if project is private
356 # used as a before_filter for actions that do not require any particular permission on the project
372 # used as a before_filter for actions that do not require any particular permission on the project
357 def check_project_privacy
373 def check_project_privacy
@@ -252,7 +252,7 class IssuesController < ApplicationController
252 @issues.sort!
252 @issues.sort!
253 @copy = params[:copy].present?
253 @copy = params[:copy].present?
254
254
255 attributes = parse_params_for_bulk_issue_attributes(params)
255 attributes = parse_params_for_bulk_update(params[:issue])
256 copy_subtasks = (params[:copy_subtasks] == '1')
256 copy_subtasks = (params[:copy_subtasks] == '1')
257 copy_attachments = (params[:copy_attachments] == '1')
257 copy_attachments = (params[:copy_attachments] == '1')
258
258
@@ -495,22 +495,6 class IssuesController < ApplicationController
495 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
495 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
496 end
496 end
497
497
498 def parse_params_for_bulk_issue_attributes(params)
499 attributes = (params[:issue] || {}).reject {|k,v| v.blank?}
500 attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
501 if custom = attributes[:custom_field_values]
502 custom.reject! {|k,v| v.blank?}
503 custom.keys.each do |k|
504 if custom[k].is_a?(Array)
505 custom[k] << '' if custom[k].delete('__none__')
506 else
507 custom[k] = '' if custom[k] == '__none__'
508 end
509 end
510 end
511 attributes
512 end
513
514 # Saves @issue and a time_entry from the parameters
498 # Saves @issue and a time_entry from the parameters
515 def save_issue_with_child_records
499 def save_issue_with_child_records
516 Issue.transaction do
500 Issue.transaction do
@@ -174,7 +174,7 class TimelogController < ApplicationController
174 end
174 end
175
175
176 def bulk_update
176 def bulk_update
177 attributes = parse_params_for_bulk_time_entry_attributes(params)
177 attributes = parse_params_for_bulk_update(params[:time_entry])
178
178
179 unsaved_time_entry_ids = []
179 unsaved_time_entry_ids = []
180 @time_entries.each do |time_entry|
180 @time_entries.each do |time_entry|
@@ -271,11 +271,4 private
271 end
271 end
272 scope
272 scope
273 end
273 end
274
275 def parse_params_for_bulk_time_entry_attributes(params)
276 attributes = (params[:time_entry] || {}).reject {|k,v| v.blank?}
277 attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
278 attributes[:custom_field_values].reject! {|k,v| v.blank?} if attributes[:custom_field_values]
279 attributes
280 end
281 end
274 end
@@ -527,6 +527,15 class TimelogControllerTest < ActionController::TestCase
527 assert_equal ["0", "0"], TimeEntry.where(:id => [1, 2]).collect {|i| i.custom_value_for(10).value}
527 assert_equal ["0", "0"], TimeEntry.where(:id => [1, 2]).collect {|i| i.custom_value_for(10).value}
528 end
528 end
529
529
530 def test_bulk_update_clear_custom_field
531 field = TimeEntryCustomField.generate!(:field_format => 'string')
532 @request.session[:user_id] = 2
533 post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {field.id.to_s => '__none__'} }
534
535 assert_response 302
536 assert_equal ["", ""], TimeEntry.where(:id => [1, 2]).collect {|i| i.custom_value_for(field).value}
537 end
538
530 def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter
539 def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter
531 @request.session[:user_id] = 2
540 @request.session[:user_id] = 2
532 post :bulk_update, :ids => [1,2], :back_url => '/time_entries'
541 post :bulk_update, :ids => [1,2], :back_url => '/time_entries'
General Comments 0
You need to be logged in to leave comments. Login now