##// END OF EJS Templates
Allow global versions to be shown outside of a project for version custom fields (#23083)....
Jean-Philippe Lang -
r15154:adb9980728c0
parent child
Show More
@@ -802,17 +802,24 module Redmine
802 projects.map {|project| possible_values_options(custom_field, project)}.reduce(:&) || []
802 projects.map {|project| possible_values_options(custom_field, project)}.reduce(:&) || []
803 elsif object.respond_to?(:project) && object.project
803 elsif object.respond_to?(:project) && object.project
804 scope = object.project.shared_versions
804 scope = object.project.shared_versions
805 if !all_statuses && custom_field.version_status.is_a?(Array)
805 filtered_versions_options(custom_field, scope, all_statuses)
806 statuses = custom_field.version_status.map(&:to_s).reject(&:blank?)
806 elsif object.nil?
807 if statuses.any?
807 scope = Version.visible.where(:sharing => 'system')
808 scope = scope.where(:status => statuses.map(&:to_s))
808 filtered_versions_options(custom_field, scope, all_statuses)
809 end
810 end
811 scope.sort.collect {|u| [u.to_s, u.id.to_s]}
812 else
809 else
813 []
810 []
814 end
811 end
815 end
812 end
813
814 def filtered_versions_options(custom_field, scope, all_statuses=false)
815 if !all_statuses && custom_field.version_status.is_a?(Array)
816 statuses = custom_field.version_status.map(&:to_s).reject(&:blank?)
817 if statuses.any?
818 scope = scope.where(:status => statuses.map(&:to_s))
819 end
820 end
821 scope.sort.collect{|u| [u.to_s, u.id.to_s] }
822 end
816 end
823 end
817 end
824 end
818 end
825 end
@@ -51,6 +51,15 class Redmine::VersionFieldFormatTest < ActionView::TestCase
51
51
52 assert_equal expected, field.possible_values_options(project).map(&:first)
52 assert_equal expected, field.possible_values_options(project).map(&:first)
53 end
53 end
54
55 def test_possible_values_options_should_return_system_shared_versions_without_project
56 field = IssueCustomField.new(:field_format => 'version')
57 version = Version.generate!(:project => Project.find(1), :status => 'open', :sharing => 'system')
58
59 expected = Version.visible.where(:sharing => 'system').sort.map(&:name)
60 assert_include version.name, expected
61 assert_equal expected, field.possible_values_options.map(&:first)
62 end
54
63
55 def test_possible_values_options_should_return_project_versions_with_selected_status
64 def test_possible_values_options_should_return_project_versions_with_selected_status
56 field = IssueCustomField.new(:field_format => 'version', :version_status => ["open"])
65 field = IssueCustomField.new(:field_format => 'version', :version_status => ["open"])
General Comments 0
You need to be logged in to leave comments. Login now