Commit 68beef69 authored by E. Levi Allen's avatar E. Levi Allen

Initial Commit on 48640

parent 2f16eab0
Pipeline #26284766 failed with stages
in 47 minutes and 46 seconds
......@@ -131,6 +131,27 @@ module QuickActions
end
end
desc do
"Returns to assigner"
end
explanation do |users|
"Returns to assigner."
end
params do
'assigner'
end
condition do
issuable.persisted? &&
issuable.assignees.any? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
end
parse_params do |pong_param|
extract_users(pong_param)
end
command :pong do |users|
@updates[:assignee_ids] = [users.first.id]
end
desc do
if issuable.allows_multiple_assignees?
'Remove all or specific assignee(s)'
......@@ -578,9 +599,11 @@ module QuickActions
users = extract_references(params, :user)
if users.empty?
users =
if params == 'me'
users = case params
when 'me'
[current_user]
when 'assigner'
[find_assigner(issuable, current_user)]
else
User.where(username: params.split(' ').map(&:strip))
end
......@@ -606,6 +629,14 @@ module QuickActions
find_labels(labels_param).map(&:id)
end
def find_assigner(issuable, current_user)
assigner = issuable.notes.where.not(author_id: current_user.id).select {|notes| notes[:note].include? "assigned to @#{current_user.username}"}.last.author
end
def find_pong_recipient(project, params = {})
log_info([project, params])
end
def explain_commands(commands)
commands.map do |name, arg|
definition = self.class.definition_by_name(name)
......
......@@ -505,6 +505,26 @@ describe QuickActions::InterpretService do
end
end
context 'pong command with assigner alias' do
let(:content) { "/pong assigner" }
context 'Issue' do
it 'fetches assigner and populates assignee_ids if content contains /assign' do
_, updates = service.execute(content, issue)
expect(updates).not_to eq(assignee_ids: [developer.id])
end
end
context 'Merge Request' do
it 'fetches assigner and populates assignee_ids if content contains /assign' do
_, updates = service.execute(content, merge_request)
expect(updates).not_to eq(assignee_ids: [developer.id])
end
end
end
it_behaves_like 'empty command' do
let(:content) { '/assign @abcd1234' }
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