Skip to content

Commit 75632ea

Browse files
authored
Merge pull request #117 from onozaty/116-add-total-hours
#116 Add total estimated hours and total spent hours for the issue to ViewCustomize.context.
2 parents 326511f + 41a1af5 commit 75632ea

File tree

5 files changed

+34
-5
lines changed

5 files changed

+34
-5
lines changed

Diff for: README.ja.md

+2
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ ViewCustomize = {
132132
"issue": {
133133
"id": 1,
134134
"author": {"id": 2, "name": "John Smith"},
135+
"totalEstimatedHours": 10.0,
136+
"totalSpentHours": 11.5,
135137
"lastUpdatedBy": {"id": 1, "name": "Redmine Admin"}
136138
}
137139
}

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ ViewCustomize = {
137137
"issue": {
138138
"id": 1,
139139
"author": {"id": 2, "name": "John Smith"},
140+
"totalEstimatedHours": 10.0,
141+
"totalSpentHours": 11.5,
140142
"lastUpdatedBy": {"id": 1, "name": "Redmine Admin"}
141143
}
142144
}

Diff for: init.rb

+1-1
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.4.1'
6+
version '3.5.0'
77
url 'https://github.com/onozaty/redmine-view-customize'
88
author_url 'https://github.com/onozaty'
99

Diff for: lib/redmine_view_customize/view_hook.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def view_issues_show_details_bottom(context={})
3232
"author" => {
3333
"id" => context[:issue].author.id,
3434
"name" => context[:issue].author.name
35-
}
35+
},
36+
"totalEstimatedHours" => context[:issue].total_estimated_hours,
37+
"totalSpentHours" => context[:issue].total_spent_hours
3638
}
3739

3840
if context[:issue].last_updated_by.present?

Diff for: test/unit/view_customize_view_hook_test.rb

+26-3
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, :journals, :custom_fields, :custom_fields_projects, :custom_values,
6+
:issues, :journals, :custom_fields, :custom_fields_projects, :custom_values, :time_entries,
77
:view_customizes
88

99
class Request
@@ -170,7 +170,7 @@ def test_view_issues_show_details_bottom
170170
171171
<script type=\"text/javascript\">
172172
//<![CDATA[
173-
ViewCustomize.context.issue = {\"id\":4,\"author\":{\"id\":2,\"name\":\"John Smith\"}};
173+
ViewCustomize.context.issue = {\"id\":4,\"author\":{\"id\":2,\"name\":\"John Smith\"},\"totalEstimatedHours\":null,\"totalSpentHours\":0.0};
174174
//]]>
175175
</script>
176176
<!-- view customize id:8 -->
@@ -193,7 +193,7 @@ def test_view_issues_show_details_bottom_with_journals
193193
194194
<script type=\"text/javascript\">
195195
//<![CDATA[
196-
ViewCustomize.context.issue = {\"id\":6,\"author\":{\"id\":2,\"name\":\"John Smith\"},\"lastUpdatedBy\":{\"id\":1,\"name\":\"Redmine Admin\"}};
196+
ViewCustomize.context.issue = {\"id\":6,\"author\":{\"id\":2,\"name\":\"John Smith\"},\"totalEstimatedHours\":null,\"totalSpentHours\":0.0,\"lastUpdatedBy\":{\"id\":1,\"name\":\"Redmine Admin\"}};
197197
//]]>
198198
</script>
199199
<!-- view customize id:8 -->
@@ -207,4 +207,27 @@ def test_view_issues_show_details_bottom_with_journals
207207

208208
end
209209

210+
def test_view_issues_show_details_bottom_with_time_entries
211+
212+
User.current = User.find(1)
213+
issue = Issue.find(1)
214+
215+
expected = <<HTML
216+
217+
<script type=\"text/javascript\">
218+
//<![CDATA[
219+
ViewCustomize.context.issue = {\"id\":1,\"author\":{\"id\":2,\"name\":\"John Smith\"},\"totalEstimatedHours\":200.0,\"totalSpentHours\":154.25,\"lastUpdatedBy\":{\"id\":2,\"name\":\"John Smith\"}};
220+
//]]>
221+
</script>
222+
<!-- view customize id:8 -->
223+
<style type=\"text/css\">
224+
code_008
225+
</style>
226+
HTML
227+
228+
html = @hook.view_issues_show_details_bottom({:request => Request.new("/issues/1"), :issue => issue, :project => @project_onlinestore})
229+
assert_equal expected, html
230+
231+
end
232+
210233
end

0 commit comments

Comments
 (0)