Commit 50e1407b authored by Kerri Miller's avatar Kerri Miller

Merge branch 'add-support-for-epic-descriptions-quick-actions-on-epic-creation-form' into 'master'

Fix quick action autocomplete in new epic form

See merge request gitlab-org/gitlab!37099
parents cccfe4b2 c4df0fbf
......@@ -17,12 +17,16 @@ module QuickActions
# rubocop: disable CodeReuse/ActiveRecord
def issue(type_id)
return project.issues.build if type_id.nil?
IssuesFinder.new(current_user, project_id: project.id).find_by(iid: type_id) || project.issues.build
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def merge_request(type_id)
return project.merge_requests.build if type_id.nil?
MergeRequestsFinder.new(current_user, project_id: project.id).find_by(iid: type_id) || project.merge_requests.build
end
# rubocop: enable CodeReuse/ActiveRecord
......
......@@ -46,10 +46,9 @@ class Groups::AutocompleteSourcesController < Groups::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def target
case params[:type]&.downcase
when 'epic'
EpicsFinder.new(current_user, group_id: @group.id).find_by(iid: params[:type_id])
end
QuickActions::TargetService
.new(nil, current_user, group: @group)
.execute(params[:type], params[:type_id])
end
# rubocop: enable CodeReuse/ActiveRecord
end
......@@ -20,7 +20,9 @@ class Groups::EpicsController < Groups::ApplicationController
push_frontend_feature_flag(:vue_issuable_epic_sidebar, @group)
end
def new; end
def new
@noteable = Epic.new
end
def index
@epics = @issuables
......
......@@ -14,6 +14,9 @@ module EE
# rubocop: disable CodeReuse/ActiveRecord
def epic(type_id)
group = params[:group]
return group.epics.build if type_id.nil?
EpicsFinder.new(current_user, group_id: group.id).find_by(iid: type_id) || group.epics.build
end
# rubocop: enable CodeReuse/ActiveRecord
......
- @gfm_form = true
- add_to_breadcrumbs _("Epics"), group_epics_path(@group)
- breadcrumb_title _("New")
- page_title _("New epic")
......
---
title: Fix quick actions autocomplete in new epic form
merge_request: 37099
author:
type: fixed
......@@ -105,5 +105,17 @@ RSpec.describe Groups::AutocompleteSourcesController do
}
)
end
it 'handles new epics' do
get :commands, params: { group_id: group, type: 'Epic', type_id: nil }
expect(json_response).to be_an(Array)
expect(json_response).to include(
{
'name' => 'cc', 'aliases' => [], 'description' => 'CC',
'params' => ['@user'], 'warning' => '', 'icon' => ''
}
)
end
end
end
......@@ -3,15 +3,39 @@
require 'spec_helper'
RSpec.describe 'GFM autocomplete', :js do
let(:user) { create(:user, name: '💃speciąl someone💃', username: 'someone.special') }
let(:group) { create(:group) }
let(:label) { create(:group_label, group: group, title: 'special+') }
let(:epic) { create(:epic, group: group) }
let_it_be(:user) { create(:user, name: '💃speciąl someone💃', username: 'someone.special') }
let_it_be(:group) { create(:group) }
let_it_be(:epic) { create(:epic, group: group) }
before_all do
group.add_maintainer(user)
end
before do
stub_licensed_features(epics: true)
group.add_maintainer(user)
sign_in(user)
end
context 'for a new epic' do
let_it_be(:label) { create(:group_label, group: group) }
before do
visit new_group_epic_path(group)
end
it 'opens quick action autocomplete in the description field' do
find('#epic-description').native.send_keys('/la')
expect(page).to have_selector('.atwho-container')
page.within '.atwho-container #at-view-commands' do
expect(find('li', match: :first)).to have_content('/label')
end
end
end
context 'for an existing epic' do
before do
visit group_epic_path(group, epic)
wait_for_requests
......@@ -78,9 +102,9 @@ RSpec.describe 'GFM autocomplete', :js do
end
context 'labels' do
let!(:backend) { create(:group_label, group: group, title: 'backend') }
let!(:bug) { create(:group_label, group: group, title: 'bug') }
let!(:feature_proposal) { create(:group_label, group: group, title: 'feature proposal') }
let_it_be(:backend) { create(:group_label, group: group, title: 'backend') }
let_it_be(:bug) { create(:group_label, group: group, title: 'bug') }
let_it_be(:feature_proposal) { create(:group_label, group: group, title: 'feature proposal') }
context 'when no labels are assigned' do
it 'shows all labels for ~' do
......@@ -204,6 +228,7 @@ RSpec.describe 'GFM autocomplete', :js do
end
end
end
end
private
......
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