]> source.dussan.org Git - redmine.git/commitdiff
Merges r14151 to r14153 (#19163).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 25 Apr 2015 07:32:42 +0000 (07:32 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 25 Apr 2015 07:32:42 +0000 (07:32 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.0-stable@14203 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
test/fixtures/custom_fields_trackers.yml
test/functional/issues_controller_test.rb

index d38b69dd1a0bfada189ca795746399502bbd990f..48608f7a704dcb7c20cdd6f07a1cda3e91b50fe3 100644 (file)
@@ -229,7 +229,7 @@ class IssuesController < ApplicationController
     else
       @available_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
     end
-    @custom_fields = target_projects.map{|p|p.all_issue_custom_fields.visible}.reduce(:&)
+    @custom_fields = @issues.map{|i|i.editable_custom_fields}.reduce(:&)
     @assignables = target_projects.map(&:assignable_users).reduce(:&)
     @trackers = target_projects.map(&:trackers).reduce(:&)
     @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&)
index 2a7a073816a30ba95efb718d56f73f07d7903d12..fc01b117ef3dcd564ec84fd4a2a324da41a0fa93 100644 (file)
@@ -26,3 +26,6 @@ custom_fields_trackers_008:
 custom_fields_trackers_009: 
   custom_field_id: 8
   tracker_id: 3
+custom_fields_trackers_010: 
+  custom_field_id: 9
+  tracker_id: 1
index dc3bd4861bdd2b129fe421f3ab070a33d54a446b..7685dc127ee31d7930c93e786f32aee43464f367 100644 (file)
@@ -3389,7 +3389,7 @@ class IssuesControllerTest < ActionController::TestCase
 
   def test_get_bulk_edit
     @request.session[:user_id] = 2
-    get :bulk_edit, :ids => [1, 2]
+    get :bulk_edit, :ids => [1, 3]
     assert_response :success
     assert_template 'bulk_edit'
 
@@ -3440,7 +3440,7 @@ class IssuesControllerTest < ActionController::TestCase
   end
 
   def test_get_bulk_edit_with_user_custom_field
-    field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true)
+    field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true, :tracker_ids => [1,2,3])
 
     @request.session[:user_id] = 2
     get :bulk_edit, :ids => [1, 2]
@@ -3453,7 +3453,7 @@ class IssuesControllerTest < ActionController::TestCase
   end
 
   def test_get_bulk_edit_with_version_custom_field
-    field = IssueCustomField.create!(:name => 'Affected version', :field_format => 'version', :is_for_all => true)
+    field = IssueCustomField.create!(:name => 'Affected version', :field_format => 'version', :is_for_all => true, :tracker_ids => [1,2,3])
 
     @request.session[:user_id] = 2
     get :bulk_edit, :ids => [1, 2]
@@ -3470,7 +3470,7 @@ class IssuesControllerTest < ActionController::TestCase
     field.update_attribute :multiple, true
 
     @request.session[:user_id] = 2
-    get :bulk_edit, :ids => [1, 2]
+    get :bulk_edit, :ids => [1, 3]
     assert_response :success
     assert_template 'bulk_edit'
 
@@ -3536,6 +3536,17 @@ class IssuesControllerTest < ActionController::TestCase
     end
   end
 
+  def test_bulk_edit_should_only_propose_issues_trackers_custom_fields
+    IssueCustomField.delete_all
+    field = IssueCustomField.generate!(:tracker_ids => [1], :is_for_all => true)
+    IssueCustomField.generate!(:tracker_ids => [2], :is_for_all => true)
+    @request.session[:user_id] = 2
+
+    issue_ids = Issue.where(:project_id => 1, :tracker_id => 1).limit(2).ids
+    get :bulk_edit, :ids => issue_ids
+    assert_equal [field], assigns(:custom_fields)
+  end
+
   def test_bulk_update
     @request.session[:user_id] = 2
     # update issues priority