mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Allow global versions to be shown outside of a project for version custom fields (#23083).
Patch by Holger Just. git-svn-id: http://svn.redmine.org/redmine/trunk@15536 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
3be2185683
commit
adb9980728
@ -802,6 +802,16 @@ module Redmine
|
|||||||
projects.map {|project| possible_values_options(custom_field, project)}.reduce(:&) || []
|
projects.map {|project| possible_values_options(custom_field, project)}.reduce(:&) || []
|
||||||
elsif object.respond_to?(:project) && object.project
|
elsif object.respond_to?(:project) && object.project
|
||||||
scope = object.project.shared_versions
|
scope = object.project.shared_versions
|
||||||
|
filtered_versions_options(custom_field, scope, all_statuses)
|
||||||
|
elsif object.nil?
|
||||||
|
scope = Version.visible.where(:sharing => 'system')
|
||||||
|
filtered_versions_options(custom_field, scope, all_statuses)
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def filtered_versions_options(custom_field, scope, all_statuses=false)
|
||||||
if !all_statuses && custom_field.version_status.is_a?(Array)
|
if !all_statuses && custom_field.version_status.is_a?(Array)
|
||||||
statuses = custom_field.version_status.map(&:to_s).reject(&:blank?)
|
statuses = custom_field.version_status.map(&:to_s).reject(&:blank?)
|
||||||
if statuses.any?
|
if statuses.any?
|
||||||
@ -809,9 +819,6 @@ module Redmine
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
scope.sort.collect{|u| [u.to_s, u.id.to_s] }
|
scope.sort.collect{|u| [u.to_s, u.id.to_s] }
|
||||||
else
|
|
||||||
[]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -52,6 +52,15 @@ class Redmine::VersionFieldFormatTest < ActionView::TestCase
|
|||||||
assert_equal expected, field.possible_values_options(project).map(&:first)
|
assert_equal expected, field.possible_values_options(project).map(&:first)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_possible_values_options_should_return_system_shared_versions_without_project
|
||||||
|
field = IssueCustomField.new(:field_format => 'version')
|
||||||
|
version = Version.generate!(:project => Project.find(1), :status => 'open', :sharing => 'system')
|
||||||
|
|
||||||
|
expected = Version.visible.where(:sharing => 'system').sort.map(&:name)
|
||||||
|
assert_include version.name, expected
|
||||||
|
assert_equal expected, field.possible_values_options.map(&:first)
|
||||||
|
end
|
||||||
|
|
||||||
def test_possible_values_options_should_return_project_versions_with_selected_status
|
def test_possible_values_options_should_return_project_versions_with_selected_status
|
||||||
field = IssueCustomField.new(:field_format => 'version', :version_status => ["open"])
|
field = IssueCustomField.new(:field_format => 'version', :version_status => ["open"])
|
||||||
project = Project.find(1)
|
project = Project.find(1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user