Commit 551e8645 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'only-show-copy_metadata-when-usable' into 'master'

Only show `/copy_metadata` when usable

See merge request gitlab-org/gitlab-ce!31735
parents af0eb56e 6639aa3f
---
title: Only show /copy_metadata quick action when usable
merge_request: 31735
author: Lee Tickett
type: fixed
......@@ -122,7 +122,7 @@ module Gitlab
params '#issue | !merge_request'
types Issue, MergeRequest
condition do
current_user.can?(:"update_#{quick_action_target.to_ability_name}", quick_action_target)
current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target)
end
parse_params do |issuable_param|
extract_references(issuable_param, :issue).first ||
......
......@@ -1140,6 +1140,19 @@ describe QuickActions::InterpretService do
let(:todo_label) { create(:label, project: project, title: 'To Do') }
let(:inreview_label) { create(:label, project: project, title: 'In Review') }
it 'is available when the user is a developer' do
expect(service.available_commands(issue)).to include(a_hash_including(name: :copy_metadata))
end
context 'when the user does not have permission' do
let(:guest) { create(:user) }
let(:service) { described_class.new(project, guest) }
it 'is not available' do
expect(service.available_commands(issue)).not_to include(a_hash_including(name: :copy_metadata))
end
end
it_behaves_like 'empty command' do
let(:content) { '/copy_metadata' }
let(:issuable) { issue }
......
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