1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-01 03:57:15 +00:00

Progress bar custom field shows only "%" instead of "0%" when value is nil (#43409).

Patch by Nishida Yuya (user:nishidayuya).


git-svn-id: https://svn.redmine.org/redmine/trunk@24112 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2025-11-03 08:23:58 +00:00
parent ca921b2eea
commit 1525eef7dd
2 changed files with 11 additions and 2 deletions

View File

@ -1146,8 +1146,9 @@ module Redmine
def formatted_value(view, custom_field, value, customized=nil, html=false)
if html
text = "#{value}%"
view.progress_bar(value.to_i, legend: (text if view.action_name == 'show'))
value_i = value.to_i
text = "#{value_i}%"
view.progress_bar(value_i, legend: (text if view.action_name == 'show'))
else
value.to_s
end

View File

@ -124,6 +124,14 @@ module Redmine::FieldFormat
assert formatted.html_safe?
end
def test_formatted_value_with_html_true_and_nil_value_as_zero
controller.action_name = 'show'
expected = progress_bar(0, legend: '0%')
formatted = @format.formatted_value(self, @field, nil, Issue.new, true)
assert_equal expected, formatted
assert formatted.html_safe?
end
def test_formatted_value_with_html_false
formatted = @format.formatted_value(self, @field, 50, Issue.new, false)
assert_equal '50', formatted