]> source.dussan.org Git - redmine.git/commitdiff
Only show statuses that can be applied to all issues on the bulk edit form (#10181).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 11 Feb 2012 12:03:48 +0000 (12:03 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 11 Feb 2012 12:03:48 +0000 (12:03 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8844 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
test/functional/issues_controller_test.rb

index 4e3fe8aefe597010eeeecff254cdace954fc6582..16a0fe723f764f4f71e2e390113fdc12c2d4feb6 100644 (file)
@@ -229,7 +229,7 @@ class IssuesController < ApplicationController
     end
     target_projects ||= @projects
 
-    @available_statuses = target_projects.map{|p|Workflow.available_statuses(p)}.reduce(:&)
+    @available_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
     @custom_fields = target_projects.map{|p|p.all_issue_custom_fields}.reduce(:&)
     @assignables = target_projects.map(&:assignable_users).reduce(:&)
     @trackers = target_projects.map(&:trackers).reduce(:&)
index 6f37bd7208eaa65a182dca8de61b07ae5eb8fb1f..9a5a7cf292415aeed4a85569cc4cd3718e6e44ab 100644 (file)
@@ -2523,6 +2523,26 @@ class IssuesControllerTest < ActionController::TestCase
       }
   end
 
+  def test_bulk_edit_should_only_propose_statuses_allowed_for_all_issues
+    Workflow.delete_all
+    Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 1)
+    Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3)
+    Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
+    Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
+    Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 3)
+    Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
+    @request.session[:user_id] = 2
+    get :bulk_edit, :ids => [1, 2]
+
+    assert_response :success
+    statuses = assigns(:available_statuses)
+    assert_not_nil statuses
+    assert_equal [1, 3], statuses.map(&:id).sort
+
+    assert_tag 'select', :attributes => {:name => 'issue[status_id]'},
+      :children => {:count => 3} # 2 statuses + "no change" option
+  end
+
   def test_bulk_update
     @request.session[:user_id] = 2
     # update issues priority