##// END OF EJS Templates
Fixed: unknown custom field format causes error when editing/bulk editing (#7985)....
Jean-Philippe Lang -
r5094:c17ff5f02490
parent child
Show More
@@ -1,5 +1,5
1 # redMine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
@@ -37,7 +37,7 module CustomFieldsHelper
37 field_id = "#{name}_custom_field_values_#{custom_field.id}"
37 field_id = "#{name}_custom_field_values_#{custom_field.id}"
38
38
39 field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
39 field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
40 case field_format.edit_as
40 case field_format.try(:edit_as)
41 when "date"
41 when "date"
42 text_field_tag(field_name, custom_value.value, :id => field_id, :size => 10) +
42 text_field_tag(field_name, custom_value.value, :id => field_id, :size => 10) +
43 calendar_for(field_id)
43 calendar_for(field_id)
@@ -72,7 +72,7 module CustomFieldsHelper
72 field_name = "#{name}[custom_field_values][#{custom_field.id}]"
72 field_name = "#{name}[custom_field_values][#{custom_field.id}]"
73 field_id = "#{name}_custom_field_values_#{custom_field.id}"
73 field_id = "#{name}_custom_field_values_#{custom_field.id}"
74 field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
74 field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
75 case field_format.edit_as
75 case field_format.try(:edit_as)
76 when "date"
76 when "date"
77 text_field_tag(field_name, '', :id => field_id, :size => 10) +
77 text_field_tag(field_name, '', :id => field_id, :size => 10) +
78 calendar_for(field_id)
78 calendar_for(field_id)
@@ -1,5 +1,5
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2009 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
@@ -26,4 +26,21 class CustomFieldsHelperTest < HelperTestCase
26 assert_equal 'Yes', format_value('1', 'bool')
26 assert_equal 'Yes', format_value('1', 'bool')
27 assert_equal 'No', format_value('0', 'bool')
27 assert_equal 'No', format_value('0', 'bool')
28 end
28 end
29
30 def test_unknow_field_format_should_be_edited_as_string
31 field = CustomField.new(:field_format => 'foo')
32 value = CustomValue.new(:value => 'bar', :custom_field => field)
33 field.id = 52
34
35 assert_equal '<input id="object_custom_field_values_52" name="object[custom_field_values][52]" type="text" value="bar" />',
36 custom_field_tag('object', value)
37 end
38
39 def test_unknow_field_format_should_be_bulk_edited_as_string
40 field = CustomField.new(:field_format => 'foo')
41 field.id = 52
42
43 assert_equal '<input id="object_custom_field_values_52" name="object[custom_field_values][52]" type="text" value="" />',
44 custom_field_tag_for_bulk_edit('object', field)
45 end
29 end
46 end
General Comments 0
You need to be logged in to leave comments. Login now