From 45284a3e73c0ba31cc167b41800f23b306bc5a35 Mon Sep 17 00:00:00 2001 From: Boris Bera Date: Wed, 6 Nov 2013 08:55:08 -0500 Subject: [PATCH 1/2] Added test for the bug in the format validation --- test/unit/custom_field_test.rb | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/test/unit/custom_field_test.rb b/test/unit/custom_field_test.rb index 051853a..2ae8022 100644 --- a/test/unit/custom_field_test.rb +++ b/test/unit/custom_field_test.rb @@ -279,4 +279,15 @@ class CustomFieldTest < ActiveSupport::TestCase assert_equal [fields[0]], CustomField.visible(User.anonymous).order("id").to_a end + + def test_field_format_validation_includes_formats_added_at_runtime + foobar_field_format_klass = Class.new(Redmine::CustomFieldFormat) + Redmine::CustomFieldFormat.map do |type| + type.register foobar_field_format_klass.new('foobar', :label => 'Foobar', :order => 1.0) + end + + field = CustomField.new(:name => 'Some Custom Field', :field_format => 'foobar') + + assert field.valid?, 'field should be valid' + end end -- 1.7.7.5 (Apple Git-26) From 55a9a866876bcd0dfa3104516a08fa1de1e80a07 Mon Sep 17 00:00:00 2001 From: Boris Bera Date: Wed, 6 Nov 2013 08:58:32 -0500 Subject: [PATCH 2/2] Fixed bug with field format validation --- app/models/custom_field.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index 34b9fb5..055516c 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -26,7 +26,7 @@ class CustomField < ActiveRecord::Base validates_presence_of :name, :field_format validates_uniqueness_of :name, :scope => :type validates_length_of :name, :maximum => 30 - validates_inclusion_of :field_format, :in => Redmine::CustomFieldFormat.available_formats + validates_inclusion_of :field_format, :in => Proc.new { Redmine::CustomFieldFormat.available_formats } validate :validate_custom_field before_validation :set_searchable -- 1.7.7.5 (Apple Git-26)