##// 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 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 if !all_statuses && custom_field.version_status.is_a?(Array)
806 statuses = custom_field.version_status.map(&:to_s).reject(&:blank?)
807 if statuses.any?
808 scope = scope.where(:status => statuses.map(&:to_s))
809 end
810 end
811 scope.sort.collect {|u| [u.to_s, u.id.to_s]}
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)
812 809 else
813 810 []
814 811 end
815 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 823 end
817 824 end
818 825 end
@@ -51,6 +51,15 class Redmine::VersionFieldFormatTest < ActionView::TestCase
51 51
52 52 assert_equal expected, field.possible_values_options(project).map(&:first)
53 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 64 def test_possible_values_options_should_return_project_versions_with_selected_status
56 65 field = IssueCustomField.new(:field_format => 'version', :version_status => ["open"])
General Comments 0
You need to be logged in to leave comments. Login now