Skip to content

Commit fe0f7cd

Browse files
committed
#116 Add total estimated hours and total spent hours to ViewCustomize.context.issue.
1 parent 326511f commit fe0f7cd

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

lib/redmine_view_customize/view_hook.rb

Lines changed: 3 additions & 1 deletion
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?

test/unit/view_customize_view_hook_test.rb

Lines changed: 26 additions & 3 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, :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)