Skip to content

Commit

Permalink
Merge pull request #117 from onozaty/116-add-total-hours
Browse files Browse the repository at this point in the history
#116 Add total estimated hours and total spent hours for the issue to ViewCustomize.context.
  • Loading branch information
onozaty committed Jan 6, 2024
2 parents 326511f + 41a1af5 commit 75632ea
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.ja.md
Expand Up @@ -132,6 +132,8 @@ ViewCustomize = {
"issue": {
"id": 1,
"author": {"id": 2, "name": "John Smith"},
"totalEstimatedHours": 10.0,
"totalSpentHours": 11.5,
"lastUpdatedBy": {"id": 1, "name": "Redmine Admin"}
}
}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -137,6 +137,8 @@ ViewCustomize = {
"issue": {
"id": 1,
"author": {"id": 2, "name": "John Smith"},
"totalEstimatedHours": 10.0,
"totalSpentHours": 11.5,
"lastUpdatedBy": {"id": 1, "name": "Redmine Admin"}
}
}
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.4.1'
version '3.5.0'
url 'https://github.com/onozaty/redmine-view-customize'
author_url 'https://github.com/onozaty'

Expand Down
4 changes: 3 additions & 1 deletion lib/redmine_view_customize/view_hook.rb
Expand Up @@ -32,7 +32,9 @@ def view_issues_show_details_bottom(context={})
"author" => {
"id" => context[:issue].author.id,
"name" => context[:issue].author.name
}
},
"totalEstimatedHours" => context[:issue].total_estimated_hours,
"totalSpentHours" => context[:issue].total_spent_hours
}

if context[:issue].last_updated_by.present?
Expand Down
29 changes: 26 additions & 3 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, :journals, :custom_fields, :custom_fields_projects, :custom_values,
:issues, :journals, :custom_fields, :custom_fields_projects, :custom_values, :time_entries,
:view_customizes

class Request
Expand Down Expand Up @@ -170,7 +170,7 @@ def test_view_issues_show_details_bottom
<script type=\"text/javascript\">
//<![CDATA[
ViewCustomize.context.issue = {\"id\":4,\"author\":{\"id\":2,\"name\":\"John Smith\"}};
ViewCustomize.context.issue = {\"id\":4,\"author\":{\"id\":2,\"name\":\"John Smith\"},\"totalEstimatedHours\":null,\"totalSpentHours\":0.0};
//]]>
</script>
<!-- view customize id:8 -->
Expand All @@ -193,7 +193,7 @@ def test_view_issues_show_details_bottom_with_journals
<script type=\"text/javascript\">
//<![CDATA[
ViewCustomize.context.issue = {\"id\":6,\"author\":{\"id\":2,\"name\":\"John Smith\"},\"lastUpdatedBy\":{\"id\":1,\"name\":\"Redmine Admin\"}};
ViewCustomize.context.issue = {\"id\":6,\"author\":{\"id\":2,\"name\":\"John Smith\"},\"totalEstimatedHours\":null,\"totalSpentHours\":0.0,\"lastUpdatedBy\":{\"id\":1,\"name\":\"Redmine Admin\"}};
//]]>
</script>
<!-- view customize id:8 -->
Expand All @@ -207,4 +207,27 @@ def test_view_issues_show_details_bottom_with_journals

end

def test_view_issues_show_details_bottom_with_time_entries

User.current = User.find(1)
issue = Issue.find(1)

expected = <<HTML
<script type=\"text/javascript\">
//<![CDATA[
ViewCustomize.context.issue = {\"id\":1,\"author\":{\"id\":2,\"name\":\"John Smith\"},\"totalEstimatedHours\":200.0,\"totalSpentHours\":154.25,\"lastUpdatedBy\":{\"id\":2,\"name\":\"John Smith\"}};
//]]>
</script>
<!-- view customize id:8 -->
<style type=\"text/css\">
code_008
</style>
HTML

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

end

end

0 comments on commit 75632ea

Please sign in to comment.