summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2024-01-04 06:55:14 +0000
committerGo MAEDA <maeda@farend.jp>2024-01-04 06:55:14 +0000
commit1ab44859feac685719b1f8f4023fec6f89b78e08 (patch)
treed2a2f9753bdd3bf2bce21e3d74a5938a0d47bc9c /test
parent82fc543ea1254bab3a727a338964472ba4906727 (diff)
downloadredmine-1ab44859feac685719b1f8f4023fec6f89b78e08.tar.gz
redmine-1ab44859feac685719b1f8f4023fec6f89b78e08.zip
Support localized decimal separators for float values (#22024).
Patch by Liane Hampe (@liane_hampe). git-svn-id: https://svn.redmine.org/redmine/trunk@22592 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/lib/redmine/field_format/numeric_format_test.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/unit/lib/redmine/field_format/numeric_format_test.rb b/test/unit/lib/redmine/field_format/numeric_format_test.rb
index 9ced022fb..c1914d2e8 100644
--- a/test/unit/lib/redmine/field_format/numeric_format_test.rb
+++ b/test/unit/lib/redmine/field_format/numeric_format_test.rb
@@ -23,6 +23,10 @@ require 'redmine/field_format'
class Redmine::NumericFieldFormatTest < ActionView::TestCase
include ApplicationHelper
+ fixtures :projects, :users, :issue_statuses, :enumerations,
+ :trackers, :projects_trackers, :roles, :member_roles,
+ :members, :enabled_modules
+
def setup
User.current = nil
end
@@ -34,4 +38,28 @@ class Redmine::NumericFieldFormatTest < ActionView::TestCase
assert_equal 3, field.format.formatted_custom_value(self, custom_value, false)
assert_equal '<a href="http://foo/3" class="external">3</a>', field.format.formatted_custom_value(self, custom_value, true)
end
+
+ def test_float_field_value_should_validate_when_given_with_various_separator
+ field = IssueCustomField.generate!(field_format: 'float')
+ issue = Issue.generate!(tracker: Tracker.find(1), status: IssueStatus.find(1), priority: IssuePriority.find(6))
+ to_test = {'en' => '3.33', 'de' => '3,33'}
+ to_test.each do |locale, expected|
+ with_locale locale do
+ assert field.format.validate_single_value(field, expected, issue)
+ end
+ end
+ end
+
+ def test_float_field_should_format_with_various_locale_separator
+ field = IssueCustomField.generate!(field_format: 'float')
+ issue = Issue.generate!(tracker: Tracker.find(1), status: IssueStatus.find(1), priority: IssuePriority.find(6))
+ issue.custom_field_values = { field.id => '1234.56' }
+ issue.save!
+ to_test = {'en' => '1234.56', 'de' => '1234,56'}
+ to_test.each do |locale, expected|
+ with_locale locale do
+ assert_equal expected, format_object(issue.reload.custom_field_values.last, false)
+ end
+ end
+ end
end