From 97939f8829b42e7dace7fce1533e457456147fb6 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 25 Apr 2015 07:32:42 +0000 Subject: [PATCH] Merges r14151 to r14153 (#19163). git-svn-id: http://svn.redmine.org/redmine/branches/3.0-stable@14203 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 2 +- test/fixtures/custom_fields_trackers.yml | 3 +++ test/functional/issues_controller_test.rb | 19 +++++++++++++++---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index d38b69dd1..48608f7a7 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -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(:&) diff --git a/test/fixtures/custom_fields_trackers.yml b/test/fixtures/custom_fields_trackers.yml index 2a7a07381..fc01b117e 100644 --- a/test/fixtures/custom_fields_trackers.yml +++ b/test/fixtures/custom_fields_trackers.yml @@ -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 diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index dc3bd4861..7685dc127 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -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 -- 2.39.5