Commit c4df0fbf authored by Heinrich Lee Yu's avatar Heinrich Lee Yu Committed by Axel García

Add controller and feature specs

Also optimizes the target service so that we don't do a useless query
parent ff61c5a8
...@@ -17,12 +17,16 @@ module QuickActions ...@@ -17,12 +17,16 @@ module QuickActions
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def issue(type_id) 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 IssuesFinder.new(current_user, project_id: project.id).find_by(iid: type_id) || project.issues.build
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def merge_request(type_id) 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 MergeRequestsFinder.new(current_user, project_id: project.id).find_by(iid: type_id) || project.merge_requests.build
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -20,7 +20,9 @@ class Groups::EpicsController < Groups::ApplicationController ...@@ -20,7 +20,9 @@ class Groups::EpicsController < Groups::ApplicationController
push_frontend_feature_flag(:vue_issuable_epic_sidebar, @group) push_frontend_feature_flag(:vue_issuable_epic_sidebar, @group)
end end
def new; end def new
@noteable = Epic.new
end
def index def index
@epics = @issuables @epics = @issuables
......
...@@ -14,6 +14,9 @@ module EE ...@@ -14,6 +14,9 @@ module EE
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def epic(type_id) def epic(type_id)
group = params[:group] 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 EpicsFinder.new(current_user, group_id: group.id).find_by(iid: type_id) || group.epics.build
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
- @gfm_form = true - @gfm_form = true
- @noteable = Epic.new
- add_to_breadcrumbs _("Epics"), group_epics_path(@group) - add_to_breadcrumbs _("Epics"), group_epics_path(@group)
- breadcrumb_title _("New") - breadcrumb_title _("New")
- page_title _("New epic") - 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 ...@@ -105,5 +105,17 @@ RSpec.describe Groups::AutocompleteSourcesController do
} }
) )
end 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
end 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