Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name 'View Customize plugin'
author 'onozaty'
description 'View Customize plugin for Redmine'
version '3.5.0'
version '3.5.1'
url 'https://github.com/onozaty/redmine-view-customize'
author_url 'https://github.com/onozaty'

Expand Down
3 changes: 2 additions & 1 deletion lib/redmine_view_customize/view_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ def create_view_customize_context(view_hook_context)
"identifier" => project.identifier,
"name" => project.name,
"roles" => user.roles_for_project(project).map {|role| { "id" => role.id, "name" => role.name }},
"customFields" => project.custom_field_values.map {|field| { "id" => field.custom_field.id, "name" => field.custom_field.name, "value" => field.value }}
# Only include custom field values which are visible to the current user
"customFields" => project.visible_custom_field_values().map {|field| { "id" => field.custom_field.id, "name" => field.custom_field.name, "value" => field.value }}
}
end

Expand Down
17 changes: 17 additions & 0 deletions test/unit/view_customize_view_hook_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ def test_view_layouts_base_html_head

end

def test_project_custom_field_visible

User.current = User.find(2)

# Change project custom filed visible
custom_field = CustomField.find(3)
custom_field.visible = false
custom_field.role_ids = [3]
custom_field.save()

expected = Regexp.escape("project\":{\"id\":1,\"identifier\":\"ecookbook\",\"name\":\"eCookbook\",\"roles\":[{\"id\":1,\"name\":\"Manager\"}],\"customFields\":[]}")

html = @hook.view_layouts_base_html_head({:request => Request.new("/issues"), :project => @project_ecookbook})
assert_match Regexp.new(expected), html

end

def test_view_layouts_base_html_head_xss

User.current = User.find(1)
Expand Down