summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-26 22:22:45 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-26 22:22:45 +0000
commitd37a30846f2c8a25645151df81900d19edd268a2 (patch)
treea2ba62366ffc0e8bd37d1d57e568f22ac695bda5
parent805864590a4988ae457b0e5d4196f11065abdb9b (diff)
downloadredmine-d37a30846f2c8a25645151df81900d19edd268a2.tar.gz
redmine-d37a30846f2c8a25645151df81900d19edd268a2.zip
Fixed: when bulk editing, setting "Assigned to" to "nobody" causes an sql error with Postgresql (#935).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1294 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/issues_controller.rb10
-rw-r--r--app/views/issues/bulk_edit.rhtml8
-rw-r--r--test/functional/issues_controller_test.rb10
3 files changed, 21 insertions, 7 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 04ff51ce9..dbc3161d7 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -206,17 +206,17 @@ class IssuesController < ApplicationController
if request.post?
status = params[:status_id].blank? ? nil : IssueStatus.find_by_id(params[:status_id])
priority = params[:priority_id].blank? ? nil : Enumeration.find_by_id(params[:priority_id])
- assigned_to = params[:assigned_to_id].blank? ? nil : User.find_by_id(params[:assigned_to_id])
- category = params[:category_id].blank? ? nil : @project.issue_categories.find_by_id(params[:category_id])
- fixed_version = params[:fixed_version_id].blank? ? nil : @project.versions.find_by_id(params[:fixed_version_id])
+ assigned_to = (params[:assigned_to_id].blank? || params[:assigned_to_id] == 'none') ? nil : User.find_by_id(params[:assigned_to_id])
+ category = (params[:category_id].blank? || params[:category_id] == 'none') ? nil : @project.issue_categories.find_by_id(params[:category_id])
+ fixed_version = (params[:fixed_version_id].blank? || params[:fixed_version_id] == 'none') ? nil : @project.versions.find_by_id(params[:fixed_version_id])
unsaved_issue_ids = []
@issues.each do |issue|
journal = issue.init_journal(User.current, params[:notes])
issue.priority = priority if priority
issue.assigned_to = assigned_to if assigned_to || params[:assigned_to_id] == 'none'
- issue.category = category if category
- issue.fixed_version = fixed_version if fixed_version
+ issue.category = category if category || params[:category_id] == 'none'
+ issue.fixed_version = fixed_version if fixed_version || params[:fixed_version_id] == 'none'
issue.start_date = params[:start_date] unless params[:start_date].blank?
issue.due_date = params[:due_date] unless params[:due_date].blank?
issue.done_ratio = params[:done_ratio] unless params[:done_ratio].blank?
diff --git a/app/views/issues/bulk_edit.rhtml b/app/views/issues/bulk_edit.rhtml
index e3f09befa..31ed7ee56 100644
--- a/app/views/issues/bulk_edit.rhtml
+++ b/app/views/issues/bulk_edit.rhtml
@@ -15,7 +15,9 @@
<label><%= l(:field_priority) %>:
<%= select_tag('priority_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(Enumeration.get_values('IPRI'), :id, :name)) %></label>
<label><%= l(:field_category) %>:
-<%= select_tag('category_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@project.issue_categories, :id, :name)) %></label>
+<%= select_tag('category_id', content_tag('option', l(:label_no_change_option), :value => '') +
+ content_tag('option', l(:label_none), :value => 'none') +
+ options_from_collection_for_select(@project.issue_categories, :id, :name)) %></label>
</p>
<p>
<label><%= l(:field_assigned_to) %>:
@@ -23,7 +25,9 @@
content_tag('option', l(:label_nobody), :value => 'none') +
options_from_collection_for_select(@project.assignable_users, :id, :name)) %></label>
<label><%= l(:field_fixed_version) %>:
-<%= select_tag('fixed_version_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@project.versions, :id, :name)) %></label>
+<%= select_tag('fixed_version_id', content_tag('option', l(:label_no_change_option), :value => '') +
+ content_tag('option', l(:label_none), :value => 'none') +
+ options_from_collection_for_select(@project.versions, :id, :name)) %></label>
</p>
<p>
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index f80110aa2..7d49f088d 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -339,6 +339,16 @@ class IssuesControllerTest < Test::Unit::TestCase
assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes
end
+ def test_bulk_unassign
+ assert_not_nil Issue.find(2).assigned_to
+ @request.session[:user_id] = 2
+ # unassign issues
+ post :bulk_edit, :ids => [1, 2], :notes => 'Bulk unassigning', :assigned_to_id => 'none'
+ assert_response 302
+ # check that the issues were updated
+ assert_nil Issue.find(2).assigned_to
+ end
+
def test_move_one_issue_to_another_project
@request.session[:user_id] = 1
post :move, :id => 1, :new_project_id => 2