Skip to content

Commit 0cb37b0

Browse files
authored
Merge pull request #97 from onozaty/develop/v3.2.0
Develop v3.2.0
2 parents 8dbda2a + 63ede48 commit 0cb37b0

File tree

6 files changed

+51
-9
lines changed

6 files changed

+51
-9
lines changed

README.ja.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ ViewCustomize = {
126126
]
127127
},
128128
"issue": {
129-
"id": 1
129+
"id": 1,
130+
"author": {"id": 2, "name": "John Smith"},
131+
"lastUpdatedBy": {"id": 1, "name": "Redmine Admin"}
130132
}
131133
}
132134
}

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ ViewCustomize = {
131131
]
132132
},
133133
"issue": {
134-
"id": 1
134+
"id": 1,
135+
"author": {"id": 2, "name": "John Smith"},
136+
"lastUpdatedBy": {"id": 1, "name": "Redmine Admin"}
135137
}
136138
}
137139
}

Vagrantfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Vagrant.configure("2") do |config|
2-
config.vm.box = "onozaty/redmine-4.1"
2+
config.vm.box = "onozaty/redmine-5.0"
33
config.vm.network "private_network", ip: "192.168.33.10"
44

55
config.vm.synced_folder ".", "/var/lib/redmine/plugins/view_customize", create: true, mount_options: ['dmode=755','fmode=655']

init.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
name 'View Customize plugin'
44
author 'onozaty'
55
description 'View Customize plugin for Redmine'
6-
version '3.1.0'
6+
version '3.2.0'
77
url 'https://github.com/onozaty/redmine-view-customize'
88
author_url 'https://github.com/onozaty'
99

lib/redmine_view_customize/view_hook.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,23 @@ def view_issues_form_details_bottom(context={})
2727

2828
def view_issues_show_details_bottom(context={})
2929

30+
issue = {
31+
"id" => context[:issue].id,
32+
"author" => {
33+
"id" => context[:issue].author.id,
34+
"name" => context[:issue].author.name
35+
}
36+
}
37+
38+
if context[:issue].last_updated_by.present?
39+
issue["lastUpdatedBy"] = {
40+
"id" => context[:issue].last_updated_by.id,
41+
"name" => context[:issue].last_updated_by.name
42+
}
43+
end
44+
3045
html = "\n<script type=\"text/javascript\">\n//<![CDATA[\n"
31-
html << "ViewCustomize.context.issue = { id: #{context[:issue].id} };"
46+
html << "ViewCustomize.context.issue = #{issue.to_json};"
3247
html << "\n//]]>\n</script>\n"
3348

3449
html << create_view_customize_html(context, ViewCustomize::INSERTION_POSITION_ISSUE_SHOW)

test/unit/view_customize_view_hook_test.rb

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class ViewCustomizeViewHookTest < ActiveSupport::TestCase
55
fixtures :projects, :users, :email_addresses, :user_preferences, :members, :member_roles, :roles,
6-
:issues, :custom_fields, :custom_fields_projects, :custom_values,
6+
:issues, :journals, :custom_fields, :custom_fields_projects, :custom_values,
77
:view_customizes
88

99
class Request
@@ -133,13 +133,13 @@ def test_view_issues_form_details_bottom
133133
def test_view_issues_show_details_bottom
134134

135135
User.current = User.find(1)
136-
issue = Issue.find(1)
136+
issue = Issue.find(4)
137137

138138
expected = <<HTML
139139
140140
<script type=\"text/javascript\">
141141
//<![CDATA[
142-
ViewCustomize.context.issue = { id: 1 };
142+
ViewCustomize.context.issue = {\"id\":4,\"author\":{\"id\":2,\"name\":\"John Smith\"}};
143143
//]]>
144144
</script>
145145
<!-- view customize id:8 -->
@@ -148,7 +148,30 @@ def test_view_issues_show_details_bottom
148148
</style>
149149
HTML
150150

151-
html = @hook.view_issues_show_details_bottom({:request => Request.new("/issues/1"), :issue => issue, :project => @project_onlinestore})
151+
html = @hook.view_issues_show_details_bottom({:request => Request.new("/issues/4"), :issue => issue, :project => @project_onlinestore})
152+
assert_equal expected, html
153+
154+
end
155+
156+
def test_view_issues_show_details_bottom_with_journals
157+
158+
User.current = User.find(1)
159+
issue = Issue.find(6)
160+
161+
expected = <<HTML
162+
163+
<script type=\"text/javascript\">
164+
//<![CDATA[
165+
ViewCustomize.context.issue = {\"id\":6,\"author\":{\"id\":2,\"name\":\"John Smith\"},\"lastUpdatedBy\":{\"id\":1,\"name\":\"Redmine Admin\"}};
166+
//]]>
167+
</script>
168+
<!-- view customize id:8 -->
169+
<style type=\"text/css\">
170+
code_008
171+
</style>
172+
HTML
173+
174+
html = @hook.view_issues_show_details_bottom({:request => Request.new("/issues/6"), :issue => issue, :project => @project_onlinestore})
152175
assert_equal expected, html
153176

154177
end

0 commit comments

Comments
 (0)