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
1fb4c850
Commit
1fb4c850
authored
Jul 06, 2020
by
Alex Kalderimis
Committed by
Alex Kalderimis
Nov 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Boards: use GlobalID scalar in update_limit_metrics
parent
bd6fdc11
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
32 deletions
+37
-32
ee/app/graphql/mutations/boards/lists/update_limit_metrics.rb
...pp/graphql/mutations/boards/lists/update_limit_metrics.rb
+5
-15
ee/spec/graphql/mutations/boards/lists/update_limit_metrics_spec.rb
...aphql/mutations/boards/lists/update_limit_metrics_spec.rb
+1
-1
ee/spec/requests/api/graphql/mutations/boards/lists/update_limit_metrics_spec.rb
...aphql/mutations/boards/lists/update_limit_metrics_spec.rb
+31
-16
No files found.
ee/app/graphql/mutations/boards/lists/update_limit_metrics.rb
View file @
1fb4c850
...
...
@@ -73,22 +73,12 @@ module Mutations
end
def
find_list_by_global_id
(
gid
)
parsed_gid
=
GlobalID
.
parse
(
gid
)
id
=
parsed_gid
.
model_id
.
to_i
if
list_accessible?
(
parsed_gid
)
return
unless
id
return
unless
gid
List
.
find_by_id
(
id
)
end
def
list_accessible?
(
gid
)
gid
.
app
==
GlobalID
.
app
&&
list?
(
gid
)
end
def
list?
(
gid
)
model_class
=
gid
&
.
model_class
return
unless
model_class
model_class
<=
List
# TODO: remove this line when the compatibility layer is removed
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
gid
=
::
Types
::
GlobalIDType
[
::
List
].
coerce_isolated_input
(
gid
)
List
.
find_by_id
(
gid
.
model_id
)
end
def
board
...
...
ee/spec/graphql/mutations/boards/lists/update_limit_metrics_spec.rb
View file @
1fb4c850
...
...
@@ -18,7 +18,7 @@ RSpec.describe Mutations::Boards::Lists::UpdateLimitMetrics do
group
.
add_guest
(
guest
)
end
subject
{
mutation
.
resolve
(
list_id:
list
.
to_global_id
.
to_s
,
**
list_update_params
)
}
subject
{
mutation
.
resolve
(
list_id:
list
.
to_global_id
,
**
list_update_params
)
}
describe
'#ready?'
do
it
'raises an error if required arguments are missing'
do
...
...
ee/spec/requests/api/graphql/mutations/boards/lists/update_limit_metrics_spec.rb
View file @
1fb4c850
...
...
@@ -9,6 +9,8 @@ RSpec.describe 'Update list limit metrics' do
let_it_be
(
:board
)
{
create
(
:board
,
group:
group
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:list
)
{
create
(
:list
,
board:
board
)
}
let_it_be
(
:forbidden_user
)
{
create
(
:user
)
}
let
(
:current_user
)
{
user
}
let
(
:mutation_class
)
{
Mutations
::
Boards
::
Lists
::
UpdateLimitMetrics
}
let
(
:mutation_name
)
{
mutation_class
.
graphql_name
}
...
...
@@ -18,39 +20,48 @@ RSpec.describe 'Update list limit metrics' do
group
.
add_maintainer
(
user
)
end
it
'returns an error if the
user is not allowed to update the issue'
do
post_graphql_mutation
(
mutation
(
'all_metrics'
),
current_user:
create
(
:user
))
context
'the current_
user is not allowed to update the issue'
do
let
(
:current_user
)
{
forbidden_user
}
expect
(
graphql_errors
).
to
include
(
a_hash_including
(
'message'
=>
"The resource that you are attempting to access does "
\
"not exist or you don't have permission to perform this action"
))
it
'returns an error'
do
perform_mutation
(
build_mutation
(
'all_metrics'
))
expect
(
graphql_errors
).
to
include
(
a_hash_including
(
'message'
=>
"The resource that you are attempting to access does "
\
"not exist or you don't have permission to perform this action"
))
end
end
it
'returns an error if the list cannot be found'
do
list_gid
=
::
URI
::
GID
.
parse
(
"gid://
#{
GlobalID
.
app
}
/List/0"
)
list_gid
=
GlobalID
.
new
(
::
Gitlab
::
GlobalId
.
build
(
model_name:
'List'
,
id:
0
)
)
p
ost_graphql_mutation
(
mutation
(
'all_metrics'
,
list_id:
list_gid
),
current_user:
create
(
:user
))
p
erform_mutation
(
build_mutation
(
'all_metrics'
,
list_id:
list_gid
.
to_s
))
expect
(
graphql_errors
).
to
include
(
a_hash_including
(
'message'
=>
"The resource that you are attempting to access does "
\
"not exist or you don't have permission to perform this action"
))
end
it
'returns an error if the gid identifies another object
'
do
post_graphql_mutation
(
mutation
(
'all_metrics'
,
list_id:
user
.
to_global_id
.
to_s
),
current_user:
create
(
:user
))
context
'the list_id is not a valid ListID
'
do
let
(
:mutation
)
{
build_mutation
(
'all_metrics'
,
list_id:
user
.
to_global_id
.
to_s
)
}
expect
(
graphql_errors
).
to
include
(
a_hash_including
(
'message'
=>
/"
#{
GitlabSchema
.
id_from_object
(
user
)
}
" does not represent an instance of List/
))
it_behaves_like
'an invalid argument to the mutation'
,
argument_name: :list_id
end
%w[all_metrics issue_count issue_weights]
.
each
do
|
metric
|
it
"updates the list limit metrics for limit metric
#{
metric
}
"
do
p
ost_graphql_mutation
(
mutation
(
metric
),
current_user:
user
)
p
erform_mutation
(
build_mutation
(
metric
)
)
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
response_list
=
json_response
[
'data'
][
mutation_result_identifier
][
'list'
]
expect
(
response_list
[
'id'
]).
to
eq
(
list
.
to_global_id
.
to_s
)
expect
(
response_list
[
'limitMetric'
]).
to
eq
(
metric
.
to_s
)
expect
(
response_list
[
'maxIssueCount'
]).
to
eq
(
3
)
expect
(
response_list
[
'maxIssueWeight'
]).
to
eq
(
42
)
expect
(
graphql_data
).
to
include
(
mutation_result_identifier
=>
include
(
'list'
=>
include
(
'id'
=>
eq
(
list
.
to_global_id
.
to_s
),
'limitMetric'
=>
eq
(
metric
.
to_s
),
'maxIssueCount'
=>
eq
(
3
),
'maxIssueWeight'
=>
eq
(
42
)
)
)
)
expect_list_update
(
list
,
metric:
metric
,
count:
3
,
weight:
42
)
end
...
...
@@ -65,7 +76,11 @@ RSpec.describe 'Update list limit metrics' do
}
end
def
mutation
(
metric
,
additional_params
=
{})
def
perform_mutation
(
mutation
)
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
end
def
build_mutation
(
metric
,
additional_params
=
{})
graphql_mutation
(
mutation_name
,
list_update_params
(
metric
).
merge
(
additional_params
),
<<-
QL
.
strip_heredoc
clientMutationId
...
...
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