Merged r11854 from trunk (#13783).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.3-stable@11995 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2013-07-11 17:51:19 +00:00
parent b5998b59ab
commit 9874a61ec3
3 changed files with 12 additions and 7 deletions

View File

@ -70,12 +70,10 @@ class EnumerationsController < ApplicationController
@enumeration.destroy
redirect_to enumerations_path
return
elsif params[:reassign_to_id]
if reassign_to = @enumeration.class.find_by_id(params[:reassign_to_id])
@enumeration.destroy(reassign_to)
redirect_to enumerations_path
return
end
elsif params[:reassign_to_id].present? && (reassign_to = @enumeration.class.find_by_id(params[:reassign_to_id].to_i))
@enumeration.destroy(reassign_to)
redirect_to enumerations_path
return
end
@enumerations = @enumeration.class.system.all - [@enumeration]
end

View File

@ -4,7 +4,7 @@
<div class="box">
<p><strong><%= l(:text_enumeration_destroy_question, @enumeration.objects_count) %></strong></p>
<p><label for='reassign_to_id'><%= l(:text_enumeration_category_reassign_to) %></label>
<%= select_tag 'reassign_to_id', (content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---") + options_from_collection_for_select(@enumerations, 'id', 'name')) %></p>
<%= select_tag 'reassign_to_id', (content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---", :value => '') + options_from_collection_for_select(@enumerations, 'id', 'name')) %></p>
</div>
<%= submit_tag l(:button_apply) %>

View File

@ -126,4 +126,11 @@ class EnumerationsControllerTest < ActionController::TestCase
# check that the issue was reassign
assert_equal 6, issue.reload.priority_id
end
def test_destroy_enumeration_in_use_with_blank_reassignment
assert_no_difference 'IssuePriority.count' do
delete :destroy, :id => 4, :reassign_to_id => ''
end
assert_response :success
end
end