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
...
@@ -73,22 +73,12 @@ module Mutations
end
end
def
find_list_by_global_id
(
gid
)
def
find_list_by_global_id
(
gid
)
parsed_gid
=
GlobalID
.
parse
(
gid
)
return
unless
gid
id
=
parsed_gid
.
model_id
.
to_i
if
list_accessible?
(
parsed_gid
)
return
unless
id
List
.
find_by_id
(
id
)
# TODO: remove this line when the compatibility layer is removed
end
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
gid
=
::
Types
::
GlobalIDType
[
::
List
].
coerce_isolated_input
(
gid
)
def
list_accessible?
(
gid
)
List
.
find_by_id
(
gid
.
model_id
)
gid
.
app
==
GlobalID
.
app
&&
list?
(
gid
)
end
def
list?
(
gid
)
model_class
=
gid
&
.
model_class
return
unless
model_class
model_class
<=
List
end
end
def
board
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
...
@@ -18,7 +18,7 @@ RSpec.describe Mutations::Boards::Lists::UpdateLimitMetrics do
group
.
add_guest
(
guest
)
group
.
add_guest
(
guest
)
end
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
describe
'#ready?'
do
it
'raises an error if required arguments are missing'
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
...
@@ -9,6 +9,8 @@ RSpec.describe 'Update list limit metrics' do
let_it_be
(
:board
)
{
create
(
:board
,
group:
group
)
}
let_it_be
(
:board
)
{
create
(
:board
,
group:
group
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:list
)
{
create
(
:list
,
board:
board
)
}
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_class
)
{
Mutations
::
Boards
::
Lists
::
UpdateLimitMetrics
}
let
(
:mutation_name
)
{
mutation_class
.
graphql_name
}
let
(
:mutation_name
)
{
mutation_class
.
graphql_name
}
...
@@ -18,39 +20,48 @@ RSpec.describe 'Update list limit metrics' do
...
@@ -18,39 +20,48 @@ RSpec.describe 'Update list limit metrics' do
group
.
add_maintainer
(
user
)
group
.
add_maintainer
(
user
)
end
end
it
'returns an error if the
user is not allowed to update the issue'
do
context
'the current_
user is not allowed to update the issue'
do
post_graphql_mutation
(
mutation
(
'all_metrics'
),
current_user:
create
(
:user
))
let
(
:current_user
)
{
forbidden_user
}
expect
(
graphql_errors
).
to
include
(
a_hash_including
(
'message'
=>
"The resource that you are attempting to access does "
\
it
'returns an error'
do
"not exist or you don't have permission to perform this action"
))
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
end
it
'returns an error if the list cannot be found'
do
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 "
\
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"
))
"not exist or you don't have permission to perform this action"
))
end
end
it
'returns an error if the gid identifies another object
'
do
context
'the list_id is not a valid ListID
'
do
post_graphql_mutation
(
mutation
(
'all_metrics'
,
list_id:
user
.
to_global_id
.
to_s
),
current_user:
create
(
:user
))
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
end
%w[all_metrics issue_count issue_weights]
.
each
do
|
metric
|
%w[all_metrics issue_count issue_weights]
.
each
do
|
metric
|
it
"updates the list limit metrics for limit metric
#{
metric
}
"
do
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
)
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
response_list
=
json_response
[
'data'
][
mutation_result_identifier
][
'list'
]
expect
(
graphql_data
).
to
include
(
expect
(
response_list
[
'id'
]).
to
eq
(
list
.
to_global_id
.
to_s
)
mutation_result_identifier
=>
include
(
expect
(
response_list
[
'limitMetric'
]).
to
eq
(
metric
.
to_s
)
'list'
=>
include
(
expect
(
response_list
[
'maxIssueCount'
]).
to
eq
(
3
)
'id'
=>
eq
(
list
.
to_global_id
.
to_s
),
expect
(
response_list
[
'maxIssueWeight'
]).
to
eq
(
42
)
'limitMetric'
=>
eq
(
metric
.
to_s
),
'maxIssueCount'
=>
eq
(
3
),
'maxIssueWeight'
=>
eq
(
42
)
)
)
)
expect_list_update
(
list
,
metric:
metric
,
count:
3
,
weight:
42
)
expect_list_update
(
list
,
metric:
metric
,
count:
3
,
weight:
42
)
end
end
...
@@ -65,7 +76,11 @@ RSpec.describe 'Update list limit metrics' do
...
@@ -65,7 +76,11 @@ RSpec.describe 'Update list limit metrics' do
}
}
end
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
),
graphql_mutation
(
mutation_name
,
list_update_params
(
metric
).
merge
(
additional_params
),
<<-
QL
.
strip_heredoc
<<-
QL
.
strip_heredoc
clientMutationId
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