summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/issue.rb2
-rw-r--r--test/unit/issue_test.rb10
2 files changed, 11 insertions, 1 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index dddb9df6b..6e69b5560 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -2069,7 +2069,7 @@ class Issue < ActiveRecord::Base
tracker.disabled_core_fields.each do |attribute|
send "#{attribute}=", nil
end
- self.priority_id ||= IssuePriority.default&.id || IssuePriority.active.first.id
+ self.priority_id ||= IssuePriority.default&.id || IssuePriority.active.first&.id
self.done_ratio ||= 0
end
end
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index 34739b62f..3be86a1a4 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -83,6 +83,16 @@ class IssueTest < ActiveSupport::TestCase
assert_save issue
end
+ def test_create_with_no_priority_defined
+ IssuePriority.delete_all
+ issue = Issue.new(
+ project_id: 1, tracker_id: 1, author_id: 3, subject: 'test_create_with_no_priority_defined'
+ )
+
+ assert_nothing_raised {assert_not issue.save}
+ assert_include 'Priority cannot be blank', issue.errors.full_messages
+ end
+
def test_default_priority_should_be_set_when_priority_field_is_disabled
tracker = Tracker.find(1)
tracker.core_fields = tracker.core_fields - ['priority_id']