@@ -656,7 +656,7 class Issue < ActiveRecord::Base | |||||
656 | if attribute =~ /^\d+$/ |
|
656 | if attribute =~ /^\d+$/ | |
657 | attribute = attribute.to_i |
|
657 | attribute = attribute.to_i | |
658 | v = custom_field_values.detect {|v| v.custom_field_id == attribute } |
|
658 | v = custom_field_values.detect {|v| v.custom_field_id == attribute } | |
659 |
if v && v.value. |
|
659 | if v && Array(v.value).detect(&:present?).nil? | |
660 | errors.add :base, v.custom_field.name + ' ' + l('activerecord.errors.messages.blank') |
|
660 | errors.add :base, v.custom_field.name + ' ' + l('activerecord.errors.messages.blank') | |
661 | end |
|
661 | end | |
662 | else |
|
662 | else |
@@ -2084,6 +2084,31 class IssuesControllerTest < ActionController::TestCase | |||||
2084 | assert_select_error /Bar cannot be blank/i |
|
2084 | assert_select_error /Bar cannot be blank/i | |
2085 | end |
|
2085 | end | |
2086 |
|
2086 | |||
|
2087 | def test_create_should_validate_required_list_fields | |||
|
2088 | cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'list', :is_for_all => true, :tracker_ids => [1, 2], :multiple => false, :possible_values => ['a', 'b']) | |||
|
2089 | cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'list', :is_for_all => true, :tracker_ids => [1, 2], :multiple => true, :possible_values => ['a', 'b']) | |||
|
2090 | WorkflowPermission.delete_all | |||
|
2091 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf1.id.to_s, :rule => 'required') | |||
|
2092 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'required') | |||
|
2093 | @request.session[:user_id] = 2 | |||
|
2094 | ||||
|
2095 | assert_no_difference 'Issue.count' do | |||
|
2096 | post :create, :project_id => 1, :issue => { | |||
|
2097 | :tracker_id => 2, | |||
|
2098 | :status_id => 1, | |||
|
2099 | :subject => 'Test', | |||
|
2100 | :start_date => '', | |||
|
2101 | :due_date => '', | |||
|
2102 | :custom_field_values => {cf1.id.to_s => '', cf2.id.to_s => ['']} | |||
|
2103 | } | |||
|
2104 | assert_response :success | |||
|
2105 | assert_template 'new' | |||
|
2106 | end | |||
|
2107 | ||||
|
2108 | assert_select_error /Foo cannot be blank/i | |||
|
2109 | assert_select_error /Bar cannot be blank/i | |||
|
2110 | end | |||
|
2111 | ||||
2087 | def test_create_should_ignore_readonly_fields |
|
2112 | def test_create_should_ignore_readonly_fields | |
2088 | cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2]) |
|
2113 | cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2]) | |
2089 | cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2]) |
|
2114 | 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