Project

General

Profile

Defect #31637 » 0001-Fix-timespan-format-of-PDF-download.patch

Seiei Miyagi, 2020-07-23 10:22

View differences:

lib/redmine/export/pdf/issues_pdf_helper.rb
21 21
  module Export
22 22
    module PDF
23 23
      module IssuesPdfHelper
24
        include Redmine::I18n
25

  
24 26
        # Returns a PDF string of a single issue
25 27
        def issue_to_pdf(issue, assoc={})
26 28
          pdf = ITCPDF.new(current_language)
......
385 387
                  value = "  " * level + value
386 388
                when :attachments
387 389
                  value = value.to_a.map {|a| a.filename}.join("\n")
390
                when :hours, :estimated_hours, :total_estimated_hours, :spent_hours, :total_spent_hours
391
                  value = format_hours(value)
388 392
                end
389 393
                if value.is_a?(Date)
390 394
                  format_date(value)
test/unit/lib/redmine/export/pdf/issues_pdf_test.rb
25 25

  
26 26
  include Redmine::Export::PDF::IssuesPdfHelper
27 27

  
28
  def test_fetch_row_values_should_round_float_values
28
  def test_fetch_row_values_should_follow_timestamp_format_setting
29 29
    query = IssueQuery.new(:project => Project.find(1), :name => '_')
30 30
    query.column_names = [:subject, :spent_hours]
31 31
    issue = Issue.find(2)
......
33 33
    time_entry = TimeEntry.create!(:spent_on => Date.today, :hours => 4.3432, :user => user, :author => user,
34 34
                     :project_id => 1, :issue => issue, :activity => TimeEntryActivity.first)
35 35

  
36
    results = fetch_row_values(issue, query, 0)
37
    assert_equal ["2", "Add ingredients categories", "4.34"], results
36
    with_settings timespan_format: 'decimal' do
37
      results = fetch_row_values(issue, query, 0)
38
      assert_equal ["2", "Add ingredients categories", "4.34"], results
39
    end
40

  
41
    with_settings timespan_format: 'minutes' do
42
      results = fetch_row_values(issue, query, 0)
43
      assert_equal ["2", "Add ingredients categories", "4:21"], results
44
    end
38 45
  end
39 46

  
40 47
  def test_fetch_row_values_should_be_able_to_handle_parent_issue_subject
(2-2/2)