From 3bef00024625218f8c67bda72a2ea40ad9c603e0 Mon Sep 17 00:00:00 2001 From: onozaty Date: Sun, 4 Dec 2022 21:06:14 +0900 Subject: [PATCH 1/3] Change Redmine version for verification --- Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index f3d6c93..5fe2f3e 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,5 +1,5 @@ Vagrant.configure("2") do |config| - config.vm.box = "onozaty/redmine-4.1" + config.vm.box = "onozaty/redmine-5.0" config.vm.network "private_network", ip: "192.168.33.10" config.vm.synced_folder ".", "/var/lib/redmine/plugins/view_customize", create: true, mount_options: ['dmode=755','fmode=655'] From 64659018d5f42bd9b58ae68a52a44d48291d3616 Mon Sep 17 00:00:00 2001 From: onozaty Date: Sun, 4 Dec 2022 22:58:27 +0900 Subject: [PATCH 2/3] Add the issue's author and last updated by to ViewCustomize.context #96 --- README.ja.md | 4 ++- README.md | 4 ++- lib/redmine_view_customize/view_hook.rb | 17 +++++++++++- test/unit/view_customize_view_hook_test.rb | 31 +++++++++++++++++++--- 4 files changed, 49 insertions(+), 7 deletions(-) diff --git a/README.ja.md b/README.ja.md index 2e465bd..92806b2 100644 --- a/README.ja.md +++ b/README.ja.md @@ -126,7 +126,9 @@ ViewCustomize = { ] }, "issue": { - "id": 1 + "id": 1, + "author": {"id": 2, "name": "John Smith"}, + "lastUpdatedBy": {"id": 1, "name": "Redmine Admin"} } } } diff --git a/README.md b/README.md index 1264093..f609142 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,9 @@ ViewCustomize = { ] }, "issue": { - "id": 1 + "id": 1, + "author": {"id": 2, "name": "John Smith"}, + "lastUpdatedBy": {"id": 1, "name": "Redmine Admin"} } } } diff --git a/lib/redmine_view_customize/view_hook.rb b/lib/redmine_view_customize/view_hook.rb index 88c132f..c28ba8f 100644 --- a/lib/redmine_view_customize/view_hook.rb +++ b/lib/redmine_view_customize/view_hook.rb @@ -27,8 +27,23 @@ def view_issues_form_details_bottom(context={}) def view_issues_show_details_bottom(context={}) + issue = { + "id" => context[:issue].id, + "author" => { + "id" => context[:issue].author.id, + "name" => context[:issue].author.name + } + } + + if context[:issue].last_updated_by.present? + issue["lastUpdatedBy"] = { + "id" => context[:issue].last_updated_by.id, + "name" => context[:issue].last_updated_by.name + } + end + html = "\n\n" html << create_view_customize_html(context, ViewCustomize::INSERTION_POSITION_ISSUE_SHOW) diff --git a/test/unit/view_customize_view_hook_test.rb b/test/unit/view_customize_view_hook_test.rb index f9b6596..531c547 100644 --- a/test/unit/view_customize_view_hook_test.rb +++ b/test/unit/view_customize_view_hook_test.rb @@ -3,7 +3,7 @@ class ViewCustomizeViewHookTest < ActiveSupport::TestCase fixtures :projects, :users, :email_addresses, :user_preferences, :members, :member_roles, :roles, - :issues, :custom_fields, :custom_fields_projects, :custom_values, + :issues, :journals, :custom_fields, :custom_fields_projects, :custom_values, :view_customizes class Request @@ -133,13 +133,13 @@ def test_view_issues_form_details_bottom def test_view_issues_show_details_bottom User.current = User.find(1) - issue = Issue.find(1) + issue = Issue.find(4) expected = < // @@ -148,7 +148,30 @@ def test_view_issues_show_details_bottom HTML - html = @hook.view_issues_show_details_bottom({:request => Request.new("/issues/1"), :issue => issue, :project => @project_onlinestore}) + html = @hook.view_issues_show_details_bottom({:request => Request.new("/issues/4"), :issue => issue, :project => @project_onlinestore}) + assert_equal expected, html + + end + + def test_view_issues_show_details_bottom_with_journals + + User.current = User.find(1) + issue = Issue.find(6) + + expected = < +// + + + +HTML + + html = @hook.view_issues_show_details_bottom({:request => Request.new("/issues/6"), :issue => issue, :project => @project_onlinestore}) assert_equal expected, html end From 63ede488feba55298a22586fd93f667ca3e3c18e Mon Sep 17 00:00:00 2001 From: onozaty Date: Sun, 4 Dec 2022 23:59:31 +0900 Subject: [PATCH 3/3] Update version number to 3.2.0 --- init.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.rb b/init.rb index 42bec97..e2d6039 100644 --- a/init.rb +++ b/init.rb @@ -3,7 +3,7 @@ name 'View Customize plugin' author 'onozaty' description 'View Customize plugin for Redmine' - version '3.1.0' + version '3.2.0' url 'https://github.com/onozaty/redmine-view-customize' author_url 'https://github.com/onozaty'