From cb2b4e7ee1d130c2b41fafa08d403adcfb1379ba Mon Sep 17 00:00:00 2001 From: Holger Just Date: Wed, 5 Apr 2017 13:04:19 +0200 Subject: [PATCH] Always set spent_hours instance variables to a Float in Issue instances Without this patch, there was a change in API behavior between Redmine 3.2 and earlier and current trunk. Previously, the spent_time field used to always contain a float, e.g. 0.0. Since Redmine 3.3, it defaults to the Integer 0 possibly breaking strict API clients. --- app/models/issue.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index d7ef5eded..f08e73d24 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1052,7 +1052,7 @@ class Issue < ActiveRecord::Base # Returns the number of hours spent on this issue def spent_hours - @spent_hours ||= time_entries.sum(:hours) || 0 + @spent_hours ||= time_entries.sum(:hours) || 0.0 end # Returns the total number of hours spent on this issue and its descendants @@ -1107,7 +1107,7 @@ class Issue < ActiveRecord::Base if issues.any? hours_by_issue_id = TimeEntry.visible(user).where(:issue_id => issues.map(&:id)).group(:issue_id).sum(:hours) issues.each do |issue| - issue.instance_variable_set "@spent_hours", (hours_by_issue_id[issue.id] || 0) + issue.instance_variable_set "@spent_hours", (hours_by_issue_id[issue.id] || 0.0) end end end @@ -1120,7 +1120,7 @@ class Issue < ActiveRecord::Base " AND parent.lft <= #{Issue.table_name}.lft AND parent.rgt >= #{Issue.table_name}.rgt"). where("parent.id IN (?)", issues.map(&:id)).group("parent.id").sum(:hours) issues.each do |issue| - issue.instance_variable_set "@total_spent_hours", (hours_by_issue_id[issue.id] || 0) + issue.instance_variable_set "@total_spent_hours", (hours_by_issue_id[issue.id] || 0.0) end end end -- 2.12.0