From 89e386ea0cd73ce043ab82e092551252f42b08c2 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 22 Nov 2014 10:34:25 +0000 Subject: [PATCH] Merged r13557 (#17744). git-svn-id: http://svn.redmine.org/redmine/branches/2.6-stable@13629 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/issue.rb | 2 +- test/unit/issue_test.rb | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index dd6361e9e..c62979368 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -624,7 +624,7 @@ class Issue < ActiveRecord::Base errors.add :base, v.custom_field.name + ' ' + l('activerecord.errors.messages.blank') end else - if respond_to?(attribute) && send(attribute).blank? + if respond_to?(attribute) && send(attribute).blank? && !disabled_core_fields.include?(attribute) errors.add attribute, :blank end end diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 3454c71f5..7a8e9c46a 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -830,6 +830,26 @@ class IssueTest < ActiveSupport::TestCase assert issue.save end + def test_required_attribute_that_is_disabled_for_the_tracker_should_not_be_required + WorkflowPermission.delete_all + WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, + :role_id => 1, :field_name => 'start_date', + :rule => 'required') + user = User.find(2) + + issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1, + :subject => 'Required fields', :author => user) + assert !issue.save + assert_include "Start date can't be blank", issue.errors.full_messages + + tracker = Tracker.find(1) + tracker.core_fields -= %w(start_date) + tracker.save! + issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1, + :subject => 'Required fields', :author => user) + assert issue.save + end + def test_required_attribute_names_for_multiple_roles_should_intersect_rules WorkflowPermission.delete_all WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, -- 2.39.5