Skip to content

Commit

Permalink
Merge pull request #97 from onozaty/develop/v3.2.0
Browse files Browse the repository at this point in the history
Develop v3.2.0
  • Loading branch information
onozaty committed Dec 6, 2022
2 parents 8dbda2a + 63ede48 commit 0cb37b0
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 9 deletions.
4 changes: 3 additions & 1 deletion README.ja.md
Expand Up @@ -126,7 +126,9 @@ ViewCustomize = {
]
},
"issue": {
"id": 1
"id": 1,
"author": {"id": 2, "name": "John Smith"},
"lastUpdatedBy": {"id": 1, "name": "Redmine Admin"}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -131,7 +131,9 @@ ViewCustomize = {
]
},
"issue": {
"id": 1
"id": 1,
"author": {"id": 2, "name": "John Smith"},
"lastUpdatedBy": {"id": 1, "name": "Redmine Admin"}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion 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']
Expand Down
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.1.0'
version '3.2.0'
url 'https://github.com/onozaty/redmine-view-customize'
author_url 'https://github.com/onozaty'

Expand Down
17 changes: 16 additions & 1 deletion lib/redmine_view_customize/view_hook.rb
Expand Up @@ -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<script type=\"text/javascript\">\n//<![CDATA[\n"
html << "ViewCustomize.context.issue = { id: #{context[:issue].id} };"
html << "ViewCustomize.context.issue = #{issue.to_json};"
html << "\n//]]>\n</script>\n"

html << create_view_customize_html(context, ViewCustomize::INSERTION_POSITION_ISSUE_SHOW)
Expand Down
31 changes: 27 additions & 4 deletions test/unit/view_customize_view_hook_test.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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 = <<HTML
<script type=\"text/javascript\">
//<![CDATA[
ViewCustomize.context.issue = { id: 1 };
ViewCustomize.context.issue = {\"id\":4,\"author\":{\"id\":2,\"name\":\"John Smith\"}};
//]]>
</script>
<!-- view customize id:8 -->
Expand All @@ -148,7 +148,30 @@ def test_view_issues_show_details_bottom
</style>
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
<script type=\"text/javascript\">
//<![CDATA[
ViewCustomize.context.issue = {\"id\":6,\"author\":{\"id\":2,\"name\":\"John Smith\"},\"lastUpdatedBy\":{\"id\":1,\"name\":\"Redmine Admin\"}};
//]]>
</script>
<!-- view customize id:8 -->
<style type=\"text/css\">
code_008
</style>
HTML

html = @hook.view_issues_show_details_bottom({:request => Request.new("/issues/6"), :issue => issue, :project => @project_onlinestore})
assert_equal expected, html

end
Expand Down

0 comments on commit 0cb37b0

Please sign in to comment.