##// 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,6 +802,16 module Redmine
802 802 projects.map {|project| possible_values_options(custom_field, project)}.reduce(:&) || []
803 803 elsif object.respond_to?(:project) && object.project
804 804 scope = object.project.shared_versions
805 filtered_versions_options(custom_field, scope, all_statuses)
806 elsif object.nil?
807 scope = Version.visible.where(:sharing => 'system')
808 filtered_versions_options(custom_field, scope, all_statuses)
809 else
810 []
811 end
812 end
813
814 def filtered_versions_options(custom_field, scope, all_statuses=false)
805 815 if !all_statuses && custom_field.version_status.is_a?(Array)
806 816 statuses = custom_field.version_status.map(&:to_s).reject(&:blank?)
807 817 if statuses.any?
@@ -809,9 +819,6 module Redmine
809 819 end
810 820 end
811 821 scope.sort.collect {|u| [u.to_s, u.id.to_s]}
812 else
813 []
814 end
815 822 end
816 823 end
817 824 end
@@ -52,6 +52,15 class Redmine::VersionFieldFormatTest < ActionView::TestCase
52 52 assert_equal expected, field.possible_values_options(project).map(&:first)
53 53 end
54 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
63
55 64 def test_possible_values_options_should_return_project_versions_with_selected_status
56 65 field = IssueCustomField.new(:field_format => 'version', :version_status => ["open"])
57 66 project = Project.find(1)
General Comments 0
You need to be logged in to leave comments. Login now