mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
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
This commit is contained in:
parent
5282a45b9b
commit
c76c0900bb
@ -19,4 +19,9 @@ class ProjectCustomField < CustomField
|
|||||||
def type_name
|
def type_name
|
||||||
:label_project_plural
|
:label_project_plural
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def visibility_by_project_condition(project_key=nil, user=User.current, id_column=nil)
|
||||||
|
project_key ||= "#{Project.table_name}.id"
|
||||||
|
super(project_key, user, id_column)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -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')
|
||||||
assert_equal -12.5, field.cast_value('-12.5')
|
assert_equal -12.5, field.cast_value('-12.5')
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user