You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

custom_fields_helper_test.rb 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2014 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. require File.expand_path('../../../test_helper', __FILE__)
  18. class CustomFieldsHelperTest < ActionView::TestCase
  19. include CustomFieldsHelper
  20. include Redmine::I18n
  21. include ERB::Util
  22. def test_format_boolean_value
  23. I18n.locale = 'en'
  24. assert_equal 'Yes', format_value('1', 'bool')
  25. assert_equal 'No', format_value('0', 'bool')
  26. end
  27. def test_unknow_field_format_should_be_edited_as_string
  28. field = CustomField.new(:field_format => 'foo')
  29. value = CustomValue.new(:value => 'bar', :custom_field => field)
  30. field.id = 52
  31. assert_equal '<input class="foo_cf" id="object_custom_field_values_52" name="object[custom_field_values][52]" type="text" value="bar" />',
  32. custom_field_tag('object', value)
  33. end
  34. def test_unknow_field_format_should_be_bulk_edited_as_string
  35. field = CustomField.new(:field_format => 'foo')
  36. field.id = 52
  37. assert_include '<input class="foo_cf" id="object_custom_field_values_52" name="object[custom_field_values][52]" type="text" value="" />',
  38. custom_field_tag_for_bulk_edit('object', field)
  39. end
  40. end