Mercurial > hg > soundsoftware-site
diff test/unit/custom_field_test.rb @ 1517:dffacf8a6908 redmine-2.5
Update to Redmine SVN revision 13367 on 2.5-stable branch
author | Chris Cannam |
---|---|
date | Tue, 09 Sep 2014 09:29:00 +0100 |
parents | e248c7af89ec |
children |
line wrap: on
line diff
--- a/test/unit/custom_field_test.rb Tue Sep 09 09:28:31 2014 +0100 +++ b/test/unit/custom_field_test.rb Tue Sep 09 09:29:00 2014 +0100 @@ -63,12 +63,12 @@ end def test_field_format_validation_should_accept_formats_added_at_runtime - Redmine::CustomFieldFormat.register 'foobar' + Redmine::FieldFormat.add 'foobar', Class.new(Redmine::FieldFormat::Base) field = CustomField.new(:name => 'Some Custom Field', :field_format => 'foobar') assert field.valid?, 'field should be valid' ensure - Redmine::CustomFieldFormat.delete 'foobar' + Redmine::FieldFormat.delete 'foobar' end def test_should_not_change_field_format_of_existing_custom_field @@ -301,4 +301,18 @@ assert_equal [fields[0]], CustomField.visible(User.anonymous).order("id").to_a end + + def test_float_cast_blank_value_should_return_nil + field = CustomField.new(:field_format => 'float') + assert_equal nil, field.cast_value(nil) + assert_equal nil, field.cast_value('') + end + + def test_float_cast_valid_value_should_return_float + field = CustomField.new(:field_format => 'float') + assert_equal 12.0, field.cast_value('12') + assert_equal 12.5, field.cast_value('12.5') + assert_equal 12.5, field.cast_value('+12.5') + assert_equal -12.5, field.cast_value('-12.5') + end end