0001-Round-floats-to-2-digits-when-rendering-an-issue-lis_r17055.patch

Marius BALTEANU, 2017-12-06 14:31

Download (2.21 KB)

View differences:

lib/redmine/export/pdf/issues_pdf_helper.rb
384 384
                format_date(value)
385 385
              elsif value.is_a?(Time)
386 386
                format_time(value)
387
              elsif value.is_a?(Float)
388
                sprintf "%.2f", value
387 389
              else
388 390
                value
389 391
              end
test/unit/lib/redmine/export/pdf/issues_pdf_test.rb
1
# Redmine - project management software
2
# Copyright (C) 2006-2017  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
require File.expand_path('../../../../../../test_helper', __FILE__)
19

  
20
class IssuesPdfHelperTest < ActiveSupport::TestCase
21
	include Redmine::Export::PDF::IssuesPdfHelper
22

  
23
	def test_fetch_row_values_should_round_float_values
24
	  query = IssueQuery.new(:project => Project.find(1), :name => '_')
25
	  query.column_names = [:subject, :spent_hours]
26

  
27

  
28
	  issue = Issue.find(2)
29
	  TimeEntry.create(:spent_on => Date.today, :hours => 4.3432, :user => User.find(1), :project_id => 1, :issue => issue, :activity => TimeEntryActivity.first)
30

  
31
	  results = fetch_row_values(issue, query, 0) 
32

  
33
	  assert_equal ["2", "Add ingredients categories", "4.34"], results
34
	end
35
end