@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
<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) %>
# 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