Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8774

Show
Ignore:
Timestamp:
02/02/08 02:59:10 (5 months ago)
Author:
bitsweat
Message:

Fix number_to_human_size incorrectly removing trailing zeros. Closes #10099 [libc, developingchris]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_view/helpers/number_helper.rb

    r8307 r8774  
    171171          when size < 1.terabyte; "%.#{precision}f GB"  % (size / 1.0.gigabyte) 
    172172          else                    "%.#{precision}f TB"  % (size / 1.0.terabyte) 
    173         end.sub(/([0-9])\.?0+ /, '\1 '
     173        end.sub(/([0-9]\.\d*?)0+ /, '\1 ' ).sub(/\. /,' '
    174174      rescue 
    175175        nil 
  • trunk/actionpack/test/template/number_helper_test.rb

    r8564 r8774  
    8888    assert_equal '10 KB',   number_to_human_size(10.000.kilobytes, 4) 
    8989    assert_equal '1 Byte',   number_to_human_size(1.1) 
     90    assert_equal '10 Bytes', number_to_human_size(10) 
    9091    assert_nil number_to_human_size('x') 
    9192    assert_nil number_to_human_size(nil)