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
6e152662
Commit
6e152662
authored
Sep 06, 2021
by
Eugenia Grieff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #can_assign_epic? method
- Fix specs
parent
459318fe
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
25 deletions
+19
-25
ee/app/models/ee/issue.rb
ee/app/models/ee/issue.rb
+1
-1
ee/app/services/ee/issues/base_service.rb
ee/app/services/ee/issues/base_service.rb
+1
-9
ee/app/services/epic_issues/create_service.rb
ee/app/services/epic_issues/create_service.rb
+8
-8
ee/spec/models/issue_spec.rb
ee/spec/models/issue_spec.rb
+4
-6
ee/spec/services/epic_issues/create_service_spec.rb
ee/spec/services/epic_issues/create_service_spec.rb
+5
-1
No files found.
ee/app/models/ee/issue.rb
View file @
6e152662
...
@@ -150,7 +150,7 @@ module EE
...
@@ -150,7 +150,7 @@ module EE
end
end
def
can_assign_epic?
(
user
)
def
can_assign_epic?
(
user
)
user
&
.
can?
(
:admin_epic
,
project
.
group
)
project
.
group
&
.
feature_available?
(
:epics
)
&&
user
&
.
can?
(
:admin_issue
,
project
)
end
end
def
can_be_promoted_to_epic?
(
user
,
group
=
nil
)
def
can_be_promoted_to_epic?
(
user
,
group
=
nil
)
...
...
ee/app/services/ee/issues/base_service.rb
View file @
6e152662
...
@@ -48,15 +48,7 @@ module EE
...
@@ -48,15 +48,7 @@ module EE
def
epic_param
(
issue
)
def
epic_param
(
issue
)
epic_id
=
params
.
delete
(
:epic_id
)
epic_id
=
params
.
delete
(
:epic_id
)
epic
=
params
.
delete
(
:epic
)
||
find_epic
(
issue
,
epic_id
)
params
.
delete
(
:epic
)
||
find_epic
(
issue
,
epic_id
)
return
unless
epic
unless
can?
(
current_user
,
:admin_issue
,
issue
)
raise
::
Gitlab
::
Access
::
AccessDeniedError
end
epic
end
end
def
find_epic
(
issue
,
epic_id
)
def
find_epic
(
issue
,
epic_id
)
...
...
ee/app/services/epic_issues/create_service.rb
View file @
6e152662
...
@@ -36,14 +36,18 @@ module EpicIssues
...
@@ -36,14 +36,18 @@ module EpicIssues
def
linkable_issuables
(
issues
)
def
linkable_issuables
(
issues
)
@linkable_issues
||=
begin
@linkable_issues
||=
begin
issues
.
select
do
|
issue
|
issues
.
select
do
|
issue
|
supports_epics?
(
issue
)
&&
linkable_issue?
(
issue
)
can?
(
current_user
,
:admin_issue
,
issue
)
&&
issuable_group_descendants
.
include?
(
issue
.
project
.
group
)
&&
!
previous_related_issuables
.
include?
(
issue
)
end
end
end
end
end
end
def
linkable_issue?
(
issue
)
issue
.
supports_epic?
&&
issue
.
project
.
group
&
.
feature_available?
(
:epics
)
&&
issuable_group_descendants
.
include?
(
issue
.
project
.
group
)
&&
!
previous_related_issuables
.
include?
(
issue
)
end
def
previous_related_issuables
def
previous_related_issuables
@related_issues
||=
issuable
.
issues
.
to_a
@related_issues
||=
issuable
.
issues
.
to_a
end
end
...
@@ -51,9 +55,5 @@ module EpicIssues
...
@@ -51,9 +55,5 @@ module EpicIssues
def
issuable_group_descendants
def
issuable_group_descendants
@descendants
||=
issuable
.
group
.
self_and_descendants
@descendants
||=
issuable
.
group
.
self_and_descendants
end
end
def
supports_epics?
(
issue
)
issue
.
supports_epic?
&&
issue
.
project
.
group
&
.
feature_available?
(
:epics
)
end
end
end
end
end
ee/spec/models/issue_spec.rb
View file @
6e152662
...
@@ -816,15 +816,13 @@ RSpec.describe Issue do
...
@@ -816,15 +816,13 @@ RSpec.describe Issue do
it
'returns false'
do
it
'returns false'
do
project
.
add_developer
(
user
)
project
.
add_developer
(
user
)
expect
(
subject
).
to
be_
false
y
expect
(
subject
).
to
be_
truth
y
end
end
end
end
context
'when a user is a group member'
do
context
'when a user is not a group member'
do
it
'returns true'
do
it
'returns false'
do
group
.
add_developer
(
user
)
expect
(
subject
).
to
be_falsey
expect
(
subject
).
to
be_truthy
end
end
end
end
end
end
...
...
ee/spec/services/epic_issues/create_service_spec.rb
View file @
6e152662
...
@@ -89,6 +89,10 @@ RSpec.describe EpicIssues::CreateService do
...
@@ -89,6 +89,10 @@ RSpec.describe EpicIssues::CreateService do
context
'when epics feature is disabled'
do
context
'when epics feature is disabled'
do
subject
{
assign_issue
([
valid_reference
])
}
subject
{
assign_issue
([
valid_reference
])
}
before
do
group
.
add_developer
(
user
)
end
include_examples
'returns an error'
include_examples
'returns an error'
end
end
...
@@ -156,7 +160,7 @@ RSpec.describe EpicIssues::CreateService do
...
@@ -156,7 +160,7 @@ RSpec.describe EpicIssues::CreateService do
# and we insert 5 issues instead of 1 which we do for control count
# and we insert 5 issues instead of 1 which we do for control count
expect
{
described_class
.
new
(
epic
,
user
,
params
).
execute
}
expect
{
described_class
.
new
(
epic
,
user
,
params
).
execute
}
.
not_to
exceed_query_limit
(
control_count
)
.
not_to
exceed_query_limit
(
control_count
)
.
with_threshold
(
29
)
.
with_threshold
(
30
)
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