##// END OF EJS Templates
Merged r14670 (#20677)....
Jean-Philippe Lang -
r14418:dd4a20b3a95e
parent child
Show More
@@ -649,7 +649,7 class Issue < ActiveRecord::Base
649 if attribute =~ /^\d+$/
649 if attribute =~ /^\d+$/
650 attribute = attribute.to_i
650 attribute = attribute.to_i
651 v = custom_field_values.detect {|v| v.custom_field_id == attribute }
651 v = custom_field_values.detect {|v| v.custom_field_id == attribute }
652 if v && v.value.blank?
652 if v && Array(v.value).detect(&:present?).nil?
653 errors.add :base, v.custom_field.name + ' ' + l('activerecord.errors.messages.blank')
653 errors.add :base, v.custom_field.name + ' ' + l('activerecord.errors.messages.blank')
654 end
654 end
655 else
655 else
@@ -2046,6 +2046,31 class IssuesControllerTest < ActionController::TestCase
2046 assert_select_error /Bar cannot be blank/i
2046 assert_select_error /Bar cannot be blank/i
2047 end
2047 end
2048
2048
2049 def test_create_should_validate_required_list_fields
2050 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'list', :is_for_all => true, :tracker_ids => [1, 2], :multiple => false, :possible_values => ['a', 'b'])
2051 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'list', :is_for_all => true, :tracker_ids => [1, 2], :multiple => true, :possible_values => ['a', 'b'])
2052 WorkflowPermission.delete_all
2053 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf1.id.to_s, :rule => 'required')
2054 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'required')
2055 @request.session[:user_id] = 2
2056
2057 assert_no_difference 'Issue.count' do
2058 post :create, :project_id => 1, :issue => {
2059 :tracker_id => 2,
2060 :status_id => 1,
2061 :subject => 'Test',
2062 :start_date => '',
2063 :due_date => '',
2064 :custom_field_values => {cf1.id.to_s => '', cf2.id.to_s => ['']}
2065 }
2066 assert_response :success
2067 assert_template 'new'
2068 end
2069
2070 assert_select_error /Foo cannot be blank/i
2071 assert_select_error /Bar cannot be blank/i
2072 end
2073
2049 def test_create_should_ignore_readonly_fields
2074 def test_create_should_ignore_readonly_fields
2050 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
2075 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
2051 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
2076 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
General Comments 0
You need to be logged in to leave comments. Login now