]> source.dussan.org Git - redmine.git/commitdiff
Fixed: error when bulk editing with Postgresql
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 23 Oct 2007 17:15:00 +0000 (17:15 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 23 Oct 2007 17:15:00 +0000 (17:15 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@866 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/projects_controller.rb
app/views/issues/_bulk_edit_form.rhtml
test/functional/projects_controller_test.rb

index 960255263ba83976505558a8477f5a7ad45e9f18..377073fc94c0de348f1223b86e32ae530680adc6 100644 (file)
@@ -339,11 +339,11 @@ class ProjectsController < ApplicationController
   # Bulk edit issues
   def bulk_edit_issues
     if request.post?
-      status = IssueStatus.find_by_id(params[:status_id])
-      priority = Enumeration.find_by_id(params[:priority_id])
-      assigned_to = User.find_by_id(params[:assigned_to_id])
-      category = @project.issue_categories.find_by_id(params[:category_id])
-      fixed_version = @project.versions.find_by_id(params[:fixed_version_id])
+      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])
       issues = @project.issues.find_all_by_id(params[:issue_ids])
       unsaved_issue_ids = []      
       issues.each do |issue|
index 6ed9474288e72bad6af1bff11eed9cb0f604cb2a..bc3f62e6d50cdffa270ab14c6a2c2302b8c13441 100644 (file)
@@ -13,7 +13,7 @@
 </p>
 <p>
 <label><%= l(:field_assigned_to) %>: 
-<%= select_tag('assigned_to_id', content_tag('option', l(:label_no_change_option)) +
+<%= select_tag('assigned_to_id', content_tag('option', l(:label_no_change_option), :value => '') +
                                  content_tag('option', l(:label_nobody), :value => 'none') +
                                  options_from_collection_for_select(@project.assignable_users, :id, :name)) %></label>
 <label><%= l(:field_fixed_version) %>: 
index e9ffa30231bbcb6450c42c34898b119305257098..b7d7962b60ad9031332ee168553cba06f24216bf 100644 (file)
@@ -22,7 +22,7 @@ require 'projects_controller'
 class ProjectsController; def rescue_action(e) raise e end; end
 
 class ProjectsControllerTest < Test::Unit::TestCase
-  fixtures :projects, :users, :roles, :enabled_modules
+  fixtures :projects, :users, :roles, :enabled_modules, :enumerations
 
   def setup
     @controller = ProjectsController.new
@@ -87,11 +87,11 @@ class ProjectsControllerTest < Test::Unit::TestCase
   def test_bulk_edit_issues
     @request.session[:user_id] = 2
     # update issues priority
-    post :bulk_edit_issues, :id => 1, :issue_ids => [1, 2], :priority_id => 7, :notes => "Bulk editing"
+    post :bulk_edit_issues, :id => 1, :issue_ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => ''
     assert_response 302
     # check that the issues were updated
     assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
-    assert_equal "Bulk editing", Issue.find(1).journals.last.notes
+    assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes
   end
 \r
   def test_list_news\r