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
459318fe
Commit
459318fe
authored
Sep 02, 2021
by
Eugenia Grieff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs that check admin_epic permissions
- Remove extra checks for permissions - Recue EpicAssignmentError
parent
f97684de
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
98 additions
and
121 deletions
+98
-121
ee/app/graphql/ee/mutations/issues/update.rb
ee/app/graphql/ee/mutations/issues/update.rb
+1
-1
ee/app/services/epic_issues/create_service.rb
ee/app/services/epic_issues/create_service.rb
+5
-1
ee/spec/graphql/ee/mutations/boards/issues/issue_move_list_spec.rb
...raphql/ee/mutations/boards/issues/issue_move_list_spec.rb
+5
-20
ee/spec/graphql/mutations/issues/update_spec.rb
ee/spec/graphql/mutations/issues/update_spec.rb
+8
-2
ee/spec/requests/api/graphql/mutations/boards/issues/issue_move_list_spec.rb
...i/graphql/mutations/boards/issues/issue_move_list_spec.rb
+2
-13
ee/spec/requests/api/graphql/mutations/issues/update_spec.rb
ee/spec/requests/api/graphql/mutations/issues/update_spec.rb
+77
-84
No files found.
ee/app/graphql/ee/mutations/issues/update.rb
View file @
459318fe
...
...
@@ -17,7 +17,7 @@ module EE
def
resolve
(
**
args
)
super
rescue
::
Gitlab
::
Access
::
AccessDeniedError
rescue
::
Gitlab
::
Access
::
AccessDeniedError
,
::
Issues
::
BaseService
::
EpicAssignmentError
raise_resource_not_available_error!
end
end
...
...
ee/app/services/epic_issues/create_service.rb
View file @
459318fe
...
...
@@ -36,7 +36,7 @@ module EpicIssues
def
linkable_issuables
(
issues
)
@linkable_issues
||=
begin
issues
.
select
do
|
issue
|
issue
.
supports_epic?
&&
supports_epics?
(
issue
)
&&
can?
(
current_user
,
:admin_issue
,
issue
)
&&
issuable_group_descendants
.
include?
(
issue
.
project
.
group
)
&&
!
previous_related_issuables
.
include?
(
issue
)
...
...
@@ -51,5 +51,9 @@ module EpicIssues
def
issuable_group_descendants
@descendants
||=
issuable
.
group
.
self_and_descendants
end
def
supports_epics?
(
issue
)
issue
.
supports_epic?
&&
issue
.
project
.
group
&
.
feature_available?
(
:epics
)
end
end
end
ee/spec/graphql/ee/mutations/boards/issues/issue_move_list_spec.rb
View file @
459318fe
...
...
@@ -32,28 +32,13 @@ RSpec.describe Mutations::Boards::Issues::IssueMoveList do
end
describe
'#resolve'
do
context
'when user has access to the epic'
do
before
do
group
.
add_developer
(
user
)
end
it
'moves and repositions issue'
do
it
'moves and repositions issue and sets epic'
do
subject
expect
(
issue1
.
reload
.
epic
).
to
eq
(
epic
)
expect
(
issue1
.
relative_position
).
to
be
<
existing_issue2
.
relative_position
expect
(
issue1
.
relative_position
).
to
be
>
existing_issue1
.
relative_position
end
end
context
'when user does not have access to the epic'
do
it
'does not update issue'
do
subject
expect
(
issue1
.
reload
.
epic
).
to
be_nil
expect
(
issue1
.
relative_position
).
to
eq
(
3
)
end
end
context
'when user cannot be assigned to issue'
do
before
do
...
...
ee/spec/graphql/mutations/issues/update_spec.rb
View file @
459318fe
...
...
@@ -44,8 +44,6 @@ RSpec.describe Mutations::Issues::Update do
context
'when epics feature is disabled'
do
it
'raises an error'
do
group
.
add_developer
(
user
)
expect
{
subject
}.
to
raise_error
(
::
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
end
end
...
...
@@ -90,6 +88,14 @@ RSpec.describe Mutations::Issues::Update do
expect
(
mutated_issue
.
epic
).
to
be_nil
end
end
context
'the epic belongs to an external group'
do
let
(
:epic
)
{
create
(
:epic
)
}
it
'does not set the epic'
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
end
end
end
end
end
...
...
ee/spec/requests/api/graphql/mutations/boards/issues/issue_move_list_spec.rb
View file @
459318fe
...
...
@@ -33,11 +33,11 @@ RSpec.describe 'Reposition and move issue within board lists' do
before
do
stub_licensed_features
(
epics:
true
)
project
.
add_maintainer
(
user
)
end
context
'when user can admin
epic
'
do
context
'when user can admin
issue
'
do
before
do
project
.
add_maintainer
(
user
)
group
.
add_maintainer
(
user
)
end
...
...
@@ -77,17 +77,6 @@ RSpec.describe 'Reposition and move issue within board lists' do
end
end
context
'when user can not admin epic'
do
it
'fails with error'
do
post_graphql_mutation
(
mutation
(
params
),
current_user:
user
)
mutation_response
=
graphql_mutation_response
(
:issue_move_list
)
expect
(
mutation_response
[
'errors'
]).
to
eq
([
'You are not allowed to move the issue'
])
expect
(
mutation_response
[
'issue'
][
'epic'
]).
to
eq
(
nil
)
expect
(
mutation_response
[
'issue'
][
'relativePosition'
]).
to
eq
(
3
)
end
end
def
mutation
(
additional_params
=
{})
graphql_mutation
(
mutation_name
,
issue_move_params
.
merge
(
additional_params
),
<<-
QL
.
strip_heredoc
...
...
ee/spec/requests/api/graphql/mutations/issues/update_spec.rb
View file @
459318fe
...
...
@@ -23,6 +23,10 @@ RSpec.describe 'Update of an existing issue' do
before
do
stub_licensed_features
(
issuable_health_status:
true
)
end
context
'when user can update issue'
do
before
do
project
.
add_developer
(
current_user
)
end
...
...
@@ -42,7 +46,6 @@ RSpec.describe 'Update of an existing issue' do
before
do
stub_licensed_features
(
epics:
true
)
group
.
add_developer
(
current_user
)
end
it
'sets the epic'
do
...
...
@@ -55,17 +58,6 @@ RSpec.describe 'Update of an existing issue' do
)
end
context
'the epic is not readable to the current user'
do
let
(
:epic
)
{
create
(
:epic
)
}
it
'does not set the epic'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
expect
(
graphql_errors
).
not_to
be_blank
end
end
context
'the epic is not an epic'
do
let
(
:epic
)
{
create
(
:user
)
}
...
...
@@ -143,4 +135,5 @@ RSpec.describe 'Update of an existing issue' do
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