@@ -677,6 +677,8 class Issue < ActiveRecord::Base | |||
|
677 | 677 | end |
|
678 | 678 | else |
|
679 | 679 | if respond_to?(attribute) && send(attribute).blank? && !disabled_core_fields.include?(attribute) |
|
680 | next if attribute == 'category_id' && project.try(:issue_categories).blank? | |
|
681 | next if attribute == 'fixed_version_id' && assignable_versions.blank? | |
|
680 | 682 | errors.add attribute, :blank |
|
681 | 683 | end |
|
682 | 684 | end |
@@ -926,6 +926,30 class IssueTest < ActiveSupport::TestCase | |||
|
926 | 926 | assert issue.save |
|
927 | 927 | end |
|
928 | 928 | |
|
929 | def test_category_should_not_be_required_if_project_has_no_categories | |
|
930 | Project.find(1).issue_categories.delete_all | |
|
931 | WorkflowPermission.delete_all | |
|
932 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, | |
|
933 | :role_id => 1, :field_name => 'category_id',:rule => 'required') | |
|
934 | user = User.find(2) | |
|
935 | ||
|
936 | issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1, | |
|
937 | :subject => 'Required fields', :author => user) | |
|
938 | assert_save issue | |
|
939 | end | |
|
940 | ||
|
941 | def test_fixed_version_should_not_be_required_no_assignable_versions | |
|
942 | Version.delete_all | |
|
943 | WorkflowPermission.delete_all | |
|
944 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, | |
|
945 | :role_id => 1, :field_name => 'fixed_version_id',:rule => 'required') | |
|
946 | user = User.find(2) | |
|
947 | ||
|
948 | issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1, | |
|
949 | :subject => 'Required fields', :author => user) | |
|
950 | assert_save issue | |
|
951 | end | |
|
952 | ||
|
929 | 953 | def test_required_custom_field_that_is_not_visible_for_the_user_should_not_be_required |
|
930 | 954 | CustomField.delete_all |
|
931 | 955 | field = IssueCustomField.generate!(:is_required => true, :visible => false, :role_ids => [1], :trackers => Tracker.all, :is_for_all => true) |
General Comments 0
You need to be logged in to leave comments.
Login now