Commit 0f8007bd authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'issue_270585-block_assign_action' into 'master'

Block assign quick action for test cases

See merge request gitlab-org/gitlab!50396
parents b06d7cac d27e1b5e
......@@ -196,6 +196,10 @@ module Issuable
is_a?(Issue)
end
def supports_assignee?
false
end
def severity
return IssuableSeverity::DEFAULT unless supports_severity?
......
......@@ -9,7 +9,9 @@ module IssueAvailableFeatures
class_methods do
# EE only features are listed on EE::IssueAvailableFeatures
def available_features_for_issue_types
{}.with_indifferent_access
{
assignee: %w(issue incident)
}.with_indifferent_access
end
end
......
......@@ -434,6 +434,10 @@ class Issue < ApplicationRecord
moved_to || duplicated_to
end
def supports_assignee?
issue_type_supports?(:assignee)
end
private
def ensure_metrics
......
......@@ -1774,6 +1774,10 @@ class MergeRequest < ApplicationRecord
false
end
def supports_assignee?
true
end
private
def with_rebase_lock
......
......@@ -6,7 +6,7 @@ module EE
extend ::Gitlab::Utils::Override
def supports_epic?
is_a?(Issue) && issue_type_supports?(:epics) && project.group.present?
false
end
def supports_health_status?
......
......@@ -251,6 +251,11 @@ module EE
super || promoted_to_epic
end
override :supports_epic?
def supports_epic?
issue_type_supports?(:epics) && project.group.present?
end
private
def blocking_issues_ids
......
---
title: Block /assign quick action for test cases
merge_request: 50396
author:
type: other
......@@ -14,6 +14,7 @@ module EE
params '@user1 @user2'
types Issue, MergeRequest
condition do
quick_action_target.supports_assignee? &&
quick_action_target.allows_multiple_assignees? &&
quick_action_target.persisted? &&
current_user.can?(:"admin_#{quick_action_target.to_ability_name}", project)
......
......@@ -44,6 +44,16 @@ RSpec.describe QuickActions::InterpretService do
expect(updates[:assignee_ids]).to match_array([user.id, user3.id])
end
context 'with test_case issue type' do
it 'does not mark to update assignee' do
test_case = create(:quality_test_case, project: project)
_, updates = service.execute("/assign @#{user3.username}", test_case)
expect(updates[:assignee_ids]).to eq(nil)
end
end
context 'assign command with multiple assignees' do
it 'fetches assignee and populates assignee_ids if content contains /assign' do
issue.update!(assignee_ids: [user.id])
......@@ -207,6 +217,16 @@ RSpec.describe QuickActions::InterpretService do
expect(updates[:assignee_ids]).to match_array([current_user.id])
end
context 'with test_case issue type' do
it 'does not mark to update assignee' do
test_case = create(:quality_test_case, project: project)
_, updates = service.execute("/reassign @#{current_user.username}", test_case)
expect(updates[:assignee_ids]).to eq(nil)
end
end
end
end
......
......@@ -26,7 +26,7 @@ module Gitlab
end
types Issue, MergeRequest
condition do
current_user.can?(:"admin_#{quick_action_target.to_ability_name}", project)
quick_action_target.supports_assignee? && current_user.can?(:"admin_#{quick_action_target.to_ability_name}", project)
end
parse_params do |assignee_param|
extract_users(assignee_param)
......
......@@ -777,6 +777,11 @@ RSpec.describe QuickActions::InterpretService do
let(:issuable) { issue }
end
it_behaves_like 'assign command' do
let(:content) { "/assign @#{developer.username}" }
let(:issuable) { create(:incident, project: project) }
end
it_behaves_like 'assign command' do
let(:content) { "/assign @#{developer.username}" }
let(:issuable) { merge_request }
......
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