diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-06-18 06:02:32 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-06-18 06:02:32 +0000 |
commit | 1fb561782bd5ce4c5a9c23341dcff0411ce90426 (patch) | |
tree | 225a74f5e25ef65a3e9df120583a2af7d6587841 | |
parent | 3bd4124ab2b0afb2b427ea58a7fe8deae184d7d8 (diff) | |
download | redmine-1fb561782bd5ce4c5a9c23341dcff0411ce90426.tar.gz redmine-1fb561782bd5ce4c5a9c23341dcff0411ce90426.zip |
Merged r15532 and r15533 (#23054).
git-svn-id: http://svn.redmine.org/redmine/branches/3.2-stable@15538 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/controllers/timelog_controller.rb | 11 | ||||
-rw-r--r-- | test/functional/timelog_controller_test.rb | 9 |
2 files changed, 19 insertions, 1 deletions
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index 597160191..59efb9d78 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -275,7 +275,16 @@ private def parse_params_for_bulk_time_entry_attributes(params) attributes = (params[:time_entry] || {}).reject {|k,v| v.blank?} attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'} - attributes[:custom_field_values].reject! {|k,v| v.blank?} if attributes[:custom_field_values] + if custom = attributes[:custom_field_values] + custom.reject! {|k,v| v.blank?} + custom.keys.each do |k| + if custom[k].is_a?(Array) + custom[k] << '' if custom[k].delete('__none__') + else + custom[k] = '' if custom[k] == '__none__' + end + end + end attributes end end diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index ce6f5936c..c3e96793d 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -527,6 +527,15 @@ class TimelogControllerTest < ActionController::TestCase assert_equal ["0", "0"], TimeEntry.where(:id => [1, 2]).collect {|i| i.custom_value_for(10).value} end + def test_bulk_update_clear_custom_field + field = TimeEntryCustomField.generate!(:field_format => 'string') + @request.session[:user_id] = 2 + post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {field.id.to_s => '__none__'} } + + assert_response 302 + assert_equal ["", ""], TimeEntry.where(:id => [1, 2]).collect {|i| i.custom_value_for(field).value} + end + def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter @request.session[:user_id] = 2 post :bulk_update, :ids => [1,2], :back_url => '/time_entries' |