Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c4df0fbf
Commit
c4df0fbf
authored
Sep 24, 2020
by
Heinrich Lee Yu
Committed by
Axel García
Sep 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add controller and feature specs
Also optimizes the target service so that we don't do a useless query
parent
ff61c5a8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
182 additions
and
132 deletions
+182
-132
app/services/quick_actions/target_service.rb
app/services/quick_actions/target_service.rb
+4
-0
ee/app/controllers/groups/epics_controller.rb
ee/app/controllers/groups/epics_controller.rb
+3
-1
ee/app/services/ee/quick_actions/target_service.rb
ee/app/services/ee/quick_actions/target_service.rb
+3
-0
ee/app/views/groups/epics/new.html.haml
ee/app/views/groups/epics/new.html.haml
+0
-1
ee/changelogs/unreleased/add-support-for-epic-descriptions-quick-actions-on-epic-creation-form.yml
...epic-descriptions-quick-actions-on-epic-creation-form.yml
+5
-0
ee/spec/controllers/groups/autocomplete_sources_controller_spec.rb
...ontrollers/groups/autocomplete_sources_controller_spec.rb
+12
-0
ee/spec/features/epics/gfm_autocomplete_spec.rb
ee/spec/features/epics/gfm_autocomplete_spec.rb
+155
-130
No files found.
app/services/quick_actions/target_service.rb
View file @
c4df0fbf
...
@@ -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
...
...
ee/app/controllers/groups/epics_controller.rb
View file @
c4df0fbf
...
@@ -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
...
...
ee/app/services/ee/quick_actions/target_service.rb
View file @
c4df0fbf
...
@@ -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
...
...
ee/app/views/groups/epics/new.html.haml
View file @
c4df0fbf
-
@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"
)
...
...
ee/changelogs/unreleased/add-support-for-epic-descriptions-quick-actions-on-epic-creation-form.yml
0 → 100644
View file @
c4df0fbf
---
title
:
Fix quick actions autocomplete in new epic form
merge_request
:
37099
author
:
type
:
fixed
ee/spec/controllers/groups/autocomplete_sources_controller_spec.rb
View file @
c4df0fbf
...
@@ -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
ee/spec/features/epics/gfm_autocomplete_spec.rb
View file @
c4df0fbf
...
@@ -3,204 +3,229 @@
...
@@ -3,204 +3,229 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
'GFM autocomplete'
,
:js
do
RSpec
.
describe
'GFM autocomplete'
,
:js
do
let
(
:user
)
{
create
(
:user
,
name:
'💃speciąl someone💃'
,
username:
'someone.special'
)
}
let_it_be
(
:user
)
{
create
(
:user
,
name:
'💃speciąl someone💃'
,
username:
'someone.special'
)
}
let
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let
(
:label
)
{
create
(
:group_label
,
group:
group
,
title:
'special+'
)
}
let_it_be
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
let
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
before
do
before_all
do
stub_licensed_features
(
epics:
true
)
group
.
add_maintainer
(
user
)
group
.
add_maintainer
(
user
)
sign_in
(
user
)
visit
group_epic_path
(
group
,
epic
)
wait_for_requests
end
end
it
'opens quick action autocomplete when updating description'
do
before
do
find
(
'.js-issuable-edit'
).
click
stub_licensed_features
(
epics:
true
)
sign_in
(
user
)
find
(
'#issue-description'
).
native
.
send_keys
(
'/'
)
expect
(
page
).
to
have_selector
(
'.atwho-container'
)
end
end
context
'issuables'
do
context
'for a new epic'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
group
)
}
let_it_be
(
:label
)
{
create
(
:group_label
,
group:
group
)
}
context
'issues'
do
it
'shows issues of group'
do
issue_1
=
create
(
:issue
,
project:
project
)
issue_2
=
create
(
:issue
,
project:
project
)
type
(
find
(
'#note-body'
),
'#'
)
before
do
visit
new_group_epic_path
(
group
)
expect_resources
(
shown:
[
issue_1
,
issue_2
])
end
end
end
context
'merge requests'
do
it
'opens quick action autocomplete in the description field'
do
it
'shows merge requests of group'
do
find
(
'#epic-description'
).
native
.
send_keys
(
'/la'
)
mr_1
=
create
(
:merge_request
,
source_project:
project
)
mr_2
=
create
(
:merge_request
,
source_project:
project
,
source_branch:
'other-branch'
)
type
(
find
(
'#note-body'
),
'!
'
)
expect
(
page
).
to
have_selector
(
'.atwho-container
'
)
expect_resources
(
shown:
[
mr_1
,
mr_2
])
page
.
within
'.atwho-container #at-view-commands'
do
expect
(
find
(
'li'
,
match: :first
)).
to
have_content
(
'/label'
)
end
end
end
end
end
end
context
'epics'
do
context
'for an existing epic'
do
let!
(
:epic2
)
{
create
(
:epic
,
group:
group
,
title:
'make tea'
)
}
before
do
visit
group_epic_path
(
group
,
epic
)
it
'shows epics'
do
note
=
find
(
'#note-body'
)
# It should show all the epics on "&".
wait_for_requests
type
(
note
,
'&'
)
expect_resources
(
shown:
[
epic
,
epic2
])
end
end
end
context
'milestone'
do
it
'opens quick action autocomplete when updating description'
do
it
'shows group milestones'
do
find
(
'.js-issuable-edit'
).
click
project
=
create
(
:project
,
namespace:
group
)
milestone_1
=
create
(
:milestone
,
title:
'milestone_1'
,
group:
group
)
milestone_2
=
create
(
:milestone
,
title:
'milestone_2'
,
group:
group
)
milestone_3
=
create
(
:milestone
,
title:
'milestone_3'
,
project:
project
)
note
=
find
(
'#note-body'
)
type
(
note
,
'%
'
)
find
(
'#issue-description'
).
native
.
send_keys
(
'/
'
)
expect
_resources
(
shown:
[
milestone_1
,
milestone_2
],
not_shown:
[
milestone_3
]
)
expect
(
page
).
to
have_selector
(
'.atwho-container'
)
end
end
end
context
'labels'
do
context
'issuables'
do
let!
(
:backend
)
{
create
(
:group_label
,
group:
group
,
title:
'backend'
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
group
)
}
let!
(
:bug
)
{
create
(
:group_label
,
group:
group
,
title:
'bug'
)
}
let!
(
:feature_proposal
)
{
create
(
:group_label
,
group:
group
,
title:
'feature proposal'
)
}
context
'when no labels are assigned'
do
context
'issues'
do
it
'shows all labels for ~'
do
it
'shows issues of group'
do
note
=
find
(
'#note-body'
)
issue_1
=
create
(
:issue
,
project:
project
)
issue_2
=
create
(
:issue
,
project:
project
)
type
(
note
,
'~'
)
type
(
find
(
'#note-body'
),
'#'
)
wait_for_requests
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
expect_resources
(
shown:
[
issue_1
,
issue_2
])
end
end
end
it
'shows all labels for /label ~'
do
context
'merge requests'
do
note
=
find
(
'#note-body'
)
it
'shows merge requests of group'
do
mr_1
=
create
(
:merge_request
,
source_project:
project
)
mr_2
=
create
(
:merge_request
,
source_project:
project
,
source_branch:
'other-branch'
)
type
(
note
,
'/label ~'
)
type
(
find
(
'#note-body'
),
'!'
)
wait_for_requests
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
expect_resources
(
shown:
[
mr_1
,
mr_2
])
end
end
end
end
it
'shows all labels for /relabel ~
'
do
context
'epics
'
do
note
=
find
(
'#note-body'
)
let!
(
:epic2
)
{
create
(
:epic
,
group:
group
,
title:
'make tea'
)
}
type
(
note
,
'/relabel ~'
)
it
'shows epics'
do
wait_for_requests
note
=
find
(
'#note-body'
)
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
# It should show all the epics on "&".
type
(
note
,
'&'
)
expect_resources
(
shown:
[
epic
,
epic2
])
end
end
end
it
'shows no labels for /unlabel ~'
do
context
'milestone'
do
it
'shows group milestones'
do
project
=
create
(
:project
,
namespace:
group
)
milestone_1
=
create
(
:milestone
,
title:
'milestone_1'
,
group:
group
)
milestone_2
=
create
(
:milestone
,
title:
'milestone_2'
,
group:
group
)
milestone_3
=
create
(
:milestone
,
title:
'milestone_3'
,
project:
project
)
note
=
find
(
'#note-body'
)
note
=
find
(
'#note-body'
)
type
(
note
,
'/unlabel ~'
)
type
(
note
,
'%'
)
wait_for_requests
expect_resources
(
not_shown:
[
backend
,
bug
,
feature_proposal
])
expect_resources
(
shown:
[
milestone_1
,
milestone_2
],
not_shown:
[
milestone_3
])
end
end
end
end
context
'
when some labels are assigned
'
do
context
'
labels
'
do
before
do
let_it_be
(
:backend
)
{
create
(
:group_label
,
group:
group
,
title:
'backend'
)
}
epic
.
labels
<<
[
backend
]
let_it_be
(
:bug
)
{
create
(
:group_label
,
group:
group
,
title:
'bug'
)
}
end
let_it_be
(
:feature_proposal
)
{
create
(
:group_label
,
group:
group
,
title:
'feature proposal'
)
}
it
'shows all labels for ~'
do
context
'when no labels are assigned'
do
note
=
find
(
'#note-body'
)
it
'shows all labels for ~'
do
note
=
find
(
'#note-body'
)
type
(
note
,
'~'
)
type
(
note
,
'~'
)
wait_for_requests
wait_for_requests
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
end
end
it
'shows only unset
labels for /label ~'
do
it
'shows all
labels for /label ~'
do
note
=
find
(
'#note-body'
)
note
=
find
(
'#note-body'
)
type
(
note
,
'/label ~'
)
type
(
note
,
'/label ~'
)
wait_for_requests
wait_for_requests
expect_resources
(
shown:
[
bug
,
feature_proposal
],
not_shown:
[
backend
])
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
end
end
it
'shows all labels for /relabel ~'
do
it
'shows all labels for /relabel ~'
do
note
=
find
(
'#note-body'
)
note
=
find
(
'#note-body'
)
type
(
note
,
'/relabel ~'
)
type
(
note
,
'/relabel ~'
)
wait_for_requests
wait_for_requests
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
end
end
it
'shows only set
labels for /unlabel ~'
do
it
'shows no
labels for /unlabel ~'
do
note
=
find
(
'#note-body'
)
note
=
find
(
'#note-body'
)
type
(
note
,
'/unlabel ~'
)
type
(
note
,
'/unlabel ~'
)
wait_for_requests
wait_for_requests
expect_resources
(
shown:
[
backend
],
not_shown:
[
bug
,
feature_proposal
])
expect_resources
(
not_shown:
[
backend
,
bug
,
feature_proposal
])
end
end
end
end
context
'when all
labels are assigned'
do
context
'when some
labels are assigned'
do
before
do
before
do
epic
.
labels
<<
[
backend
,
bug
,
feature_proposal
]
epic
.
labels
<<
[
backend
]
end
end
it
'shows all labels for ~'
do
it
'shows all labels for ~'
do
note
=
find
(
'#note-body'
)
note
=
find
(
'#note-body'
)
type
(
note
,
'~'
)
type
(
note
,
'~'
)
wait_for_requests
wait_for_requests
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
end
end
it
'shows no
labels for /label ~'
do
it
'shows only unset
labels for /label ~'
do
note
=
find
(
'#note-body'
)
note
=
find
(
'#note-body'
)
type
(
note
,
'/label ~'
)
type
(
note
,
'/label ~'
)
wait_for_requests
wait_for_requests
expect_resources
(
not_shown:
[
backend
,
bug
,
feature_proposal
])
expect_resources
(
shown:
[
bug
,
feature_proposal
],
not_shown:
[
backend
])
end
end
it
'shows all labels for /relabel ~'
do
it
'shows all labels for /relabel ~'
do
note
=
find
(
'#note-body'
)
note
=
find
(
'#note-body'
)
type
(
note
,
'/relabel ~'
)
wait_for_requests
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
end
type
(
note
,
'/relabel ~'
)
it
'shows only set labels for /unlabel ~'
do
wait_for_requests
note
=
find
(
'#note-body'
)
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
type
(
note
,
'/unlabel ~'
)
wait_for_requests
expect_resources
(
shown:
[
backend
],
not_shown:
[
bug
,
feature_proposal
])
end
end
end
it
'shows all labels for /unlabel ~'
do
context
'when all labels are assigned'
do
note
=
find
(
'#note-body'
)
before
do
epic
.
labels
<<
[
backend
,
bug
,
feature_proposal
]
end
it
'shows all labels for ~'
do
note
=
find
(
'#note-body'
)
type
(
note
,
'~'
)
wait_for_requests
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
end
it
'shows no labels for /label ~'
do
note
=
find
(
'#note-body'
)
type
(
note
,
'/label ~'
)
wait_for_requests
expect_resources
(
not_shown:
[
backend
,
bug
,
feature_proposal
])
end
it
'shows all labels for /relabel ~'
do
note
=
find
(
'#note-body'
)
type
(
note
,
'/relabel ~'
)
wait_for_requests
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
end
it
'shows all labels for /unlabel ~'
do
note
=
find
(
'#note-body'
)
type
(
note
,
'/unlabel ~'
)
type
(
note
,
'/unlabel ~'
)
wait_for_requests
wait_for_requests
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
expect_resources
(
shown:
[
backend
,
bug
,
feature_proposal
])
end
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment