]> source.dussan.org Git - redmine.git/commitdiff
Merged r13557 (#17744).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 22 Nov 2014 10:34:25 +0000 (10:34 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 22 Nov 2014 10:34:25 +0000 (10:34 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/2.6-stable@13629 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb
test/unit/issue_test.rb

index dd6361e9e7d2460088aeda1f31616201b61c5e8f..c62979368094b059361d1e832ccbb234278124ea 100644 (file)
@@ -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
index 3454c71f5ff1c6d5cd4b1a0d2b5ead6fe02503b4..7a8e9c46a579fb124fa77c5917702dec85263422 100644 (file)
@@ -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,