Skip to content

Commit

Permalink
Merge pull request #121 from onozaty/develop/v3.5.1
Browse files Browse the repository at this point in the history
Develop v3.5.1
  • Loading branch information
onozaty committed Jan 20, 2024
2 parents 75632ea + 620ba9d commit fd10280
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion init.rb
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
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
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

0 comments on commit fd10280

Please sign in to comment.