@@ -804,6 +804,16 module Redmine | |||
|
804 | 804 | projects.map {|project| possible_values_options(custom_field, project)}.reduce(:&) || [] |
|
805 | 805 | elsif object.respond_to?(:project) && object.project |
|
806 | 806 | scope = object.project.shared_versions |
|
807 | filtered_versions_options(custom_field, scope, all_statuses) | |
|
808 | elsif object.nil? | |
|
809 | scope = Version.visible.where(:sharing => 'system') | |
|
810 | filtered_versions_options(custom_field, scope, all_statuses) | |
|
811 | else | |
|
812 | [] | |
|
813 | end | |
|
814 | end | |
|
815 | ||
|
816 | def filtered_versions_options(custom_field, scope, all_statuses=false) | |
|
807 | 817 |
|
|
808 | 818 |
|
|
809 | 819 |
|
@@ -811,9 +821,6 module Redmine | |||
|
811 | 821 |
|
|
812 | 822 |
|
|
813 | 823 |
|
|
814 | else | |
|
815 | [] | |
|
816 | end | |
|
817 | 824 | end |
|
818 | 825 | end |
|
819 | 826 | end |
@@ -25,6 +25,7 class CustomFieldVersionFormatTest < ActiveSupport::TestCase | |||
|
25 | 25 | end |
|
26 | 26 | |
|
27 | 27 | def test_possible_values_options_with_no_arguments |
|
28 | Version.delete_all | |
|
28 | 29 | assert_equal [], @field.possible_values_options |
|
29 | 30 | assert_equal [], @field.possible_values_options(nil) |
|
30 | 31 | 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