summaryrefslogtreecommitdiffstats
path: root/test/unit/custom_field_test.rb
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2018-09-24 05:31:13 +0000
committerGo MAEDA <maeda@farend.jp>2018-09-24 05:31:13 +0000
commitc76c0900bb49973fea7f1a5f1cecd16aadb16b6b (patch)
treee5a7637ddf8d056ed8f5278dd3a2a1293e3324c5 /test/unit/custom_field_test.rb
parent5282a45b9b8eb39a25416cf270ca423db485a976 (diff)
downloadredmine-c76c0900bb49973fea7f1a5f1cecd16aadb16b6b.tar.gz
redmine-c76c0900bb49973fea7f1a5f1cecd16aadb16b6b.zip
Use the id field as project_key in ProjectCustomField#visibility_by_project_condition by default (#29161).
Patch by Holger Just. git-svn-id: http://svn.redmine.org/redmine/trunk@17517 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/custom_field_test.rb')
-rw-r--r--test/unit/custom_field_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/unit/custom_field_test.rb b/test/unit/custom_field_test.rb
index 3eae54efa..bdf5d4842 100644
--- a/test/unit/custom_field_test.rb
+++ b/test/unit/custom_field_test.rb
@@ -340,4 +340,20 @@ class CustomFieldTest < ActiveSupport::TestCase
assert_equal 12.5, field.cast_value('+12.5')
assert_equal -12.5, field.cast_value('-12.5')
end
+
+ def test_project_custom_field_visibility
+ project_field = ProjectCustomField.generate!(:visible => false, :field_format => 'list', :possible_values => %w[a b c])
+ project = Project.find(3)
+ project.custom_field_values = { project_field.id => 'a' }
+
+ # Admins can find projects with the field
+ with_current_user(User.find(1)) do
+ assert_includes Project.where(project_field.visibility_by_project_condition), project
+ end
+
+ # The field is not visible to normal users
+ with_current_user(User.find(2)) do
+ refute_includes Project.where(project_field.visibility_by_project_condition), project
+ end
+ end
end