Skip to content

Commit

Permalink
Merge pull request #87 from onozaty/develop/v3.0.0
Browse files Browse the repository at this point in the history
* Zeitwerk support #84
* Add ViewCustomize.context.project.id #86
  • Loading branch information
onozaty committed Nov 21, 2021
2 parents 4524e12 + 4e14798 commit 14f4977
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.ja.md
Expand Up @@ -115,6 +115,7 @@ ViewCustomize = {
]
},
"project": {
"id": 1,
"identifier": "project-a",
"name": "Project A",
"roles": [
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -120,6 +120,7 @@ ViewCustomize = {
]
},
"project": {
"id": 1,
"identifier": "project-a",
"name": "Project A",
"roles": [
Expand Down
2 changes: 1 addition & 1 deletion after_init.rb
@@ -1 +1 @@
require_dependency 'view_customize/view_hook'
require File.expand_path('../lib/redmine_view_customize/view_hook', __FILE__)
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 '2.8.1'
version '3.0.0'
url 'https://github.com/onozaty/redmine-view-customize'
author_url 'https://github.com/onozaty'

Expand Down
Expand Up @@ -115,6 +115,7 @@ def create_view_customize_context(view_hook_context)
project = view_hook_context[:project]
if project
context["project"] = {
"id" => project.id,
"identifier" => project.identifier,
"name" => project.name,
"roles" => user.roles_for_project(project).map {|role| { "id" => role.id, "name" => role.name }},
Expand Down
8 changes: 5 additions & 3 deletions test/unit/view_customize_view_hook_test.rb
@@ -1,8 +1,10 @@
require File.expand_path('../../test_helper', __FILE__)
require File.expand_path('../../../lib/view_customize/view_hook', __FILE__)
require File.expand_path('../../../lib/redmine_view_customize/view_hook', __FILE__)

class ViewCustomizeViewHookTest < ActiveSupport::TestCase
fixtures :view_customizes, :projects, :users, :issues, :custom_fields, :custom_values
fixtures :projects, :users, :email_addresses, :user_preferences, :members, :member_roles, :roles,
:issues, :custom_fields, :custom_fields_projects, :custom_values,
:view_customizes

class Request
def initialize(path)
Expand Down Expand Up @@ -74,7 +76,7 @@ def test_view_layouts_base_html_head
expected << "[0-9]+"
expected << Regexp.escape("\" /><script type=\"text/javascript\">\n")
expected << Regexp.escape("//<![CDATA[\n")
expected << Regexp.escape("ViewCustomize = { context: {\"user\":{\"id\":1,\"login\":\"admin\",\"admin\":true,\"firstname\":\"Redmine\",\"lastname\":\"Admin\",\"lastLoginOn\":\"2006-07-19T20:57:52Z\",\"groups\":[],\"apiKey\":null,\"customFields\":[{\"id\":4,\"name\":\"Phone number\",\"value\":null},{\"id\":5,\"name\":\"Money\",\"value\":null}]},\"project\":{\"identifier\":\"ecookbook\",\"name\":\"eCookbook\",\"roles\":[{\"id\":1,\"name\":\"Non member\"}],\"customFields\":[{\"id\":3,\"name\":\"Development status\",\"value\":\"Stable\"}]}} };\n")
expected << Regexp.escape("ViewCustomize = { context: {\"user\":{\"id\":1,\"login\":\"admin\",\"admin\":true,\"firstname\":\"Redmine\",\"lastname\":\"Admin\",\"lastLoginOn\":\"2006-07-19T20:57:52Z\",\"groups\":[],\"apiKey\":null,\"customFields\":[{\"id\":4,\"name\":\"Phone number\",\"value\":null},{\"id\":5,\"name\":\"Money\",\"value\":null}]},\"project\":{\"id\":1,\"identifier\":\"ecookbook\",\"name\":\"eCookbook\",\"roles\":[{\"id\":4,\"name\":\"Non member\"}],\"customFields\":[{\"id\":3,\"name\":\"Development status\",\"value\":\"Stable\"}]}} };\n")
expected << Regexp.escape("//]]>\n")
expected << Regexp.escape("</script>\n")
expected << Regexp.escape("<!-- view customize id:1 -->\n")
Expand Down

0 comments on commit 14f4977

Please sign in to comment.