Commit 316479ef authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch 'pl-validate-issue-type' into 'master'

Prevent users from assigning an invalid issue type to new issues

See merge request gitlab-org/gitlab!69106
parents 08a2b304 48e31ef4
......@@ -84,7 +84,8 @@ module Issues
# @param object [Issue, Project]
def issue_type_allowed?(object)
can?(current_user, :"create_#{params[:issue_type]}", object)
WorkItem::Type.base_types.key?(params[:issue_type]) &&
can?(current_user, :"create_#{params[:issue_type]}", object)
end
# @param issue [Issue]
......
......@@ -183,8 +183,8 @@ RSpec.describe Issues::BuildService do
expect(issue).to be_incident
end
it 'cannot set invalid type' do
issue = build_issue(issue_type: 'invalid type')
it 'cannot set invalid issue type' do
issue = build_issue(issue_type: 'project')
expect(issue).to be_issue
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment