Skip to content

Commit fd10280

Browse files
authored
Merge pull request #121 from onozaty/develop/v3.5.1
Develop v3.5.1
2 parents 75632ea + 620ba9d commit fd10280

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

Diff for: init.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
name 'View Customize plugin'
44
author 'onozaty'
55
description 'View Customize plugin for Redmine'
6-
version '3.5.0'
6+
version '3.5.1'
77
url 'https://github.com/onozaty/redmine-view-customize'
88
author_url 'https://github.com/onozaty'
99

Diff for: lib/redmine_view_customize/view_hook.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ def create_view_customize_context(view_hook_context)
141141
"identifier" => project.identifier,
142142
"name" => project.name,
143143
"roles" => user.roles_for_project(project).map {|role| { "id" => role.id, "name" => role.name }},
144-
"customFields" => project.custom_field_values.map {|field| { "id" => field.custom_field.id, "name" => field.custom_field.name, "value" => field.value }}
144+
# Only include custom field values which are visible to the current user
145+
"customFields" => project.visible_custom_field_values().map {|field| { "id" => field.custom_field.id, "name" => field.custom_field.name, "value" => field.value }}
145146
}
146147
end
147148

Diff for: test/unit/view_customize_view_hook_test.rb

+17
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,23 @@ def test_view_layouts_base_html_head
9797

9898
end
9999

100+
def test_project_custom_field_visible
101+
102+
User.current = User.find(2)
103+
104+
# Change project custom filed visible
105+
custom_field = CustomField.find(3)
106+
custom_field.visible = false
107+
custom_field.role_ids = [3]
108+
custom_field.save()
109+
110+
expected = Regexp.escape("project\":{\"id\":1,\"identifier\":\"ecookbook\",\"name\":\"eCookbook\",\"roles\":[{\"id\":1,\"name\":\"Manager\"}],\"customFields\":[]}")
111+
112+
html = @hook.view_layouts_base_html_head({:request => Request.new("/issues"), :project => @project_ecookbook})
113+
assert_match Regexp.new(expected), html
114+
115+
end
116+
100117
def test_view_layouts_base_html_head_xss
101118

102119
User.current = User.find(1)

0 commit comments

Comments
 (0)