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
37d2f721
Commit
37d2f721
authored
Sep 09, 2021
by
Illya Klymov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make group and project fields fullPath argument case-insensitive
- make full path loader case-insensitive Changelog: fixed
parent
185676ce
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
3 deletions
+14
-3
lib/gitlab/graphql/loaders/full_path_model_loader.rb
lib/gitlab/graphql/loaders/full_path_model_loader.rb
+3
-2
spec/graphql/resolvers/group_resolver_spec.rb
spec/graphql/resolvers/group_resolver_spec.rb
+6
-1
spec/graphql/resolvers/project_resolver_spec.rb
spec/graphql/resolvers/project_resolver_spec.rb
+5
-0
No files found.
lib/gitlab/graphql/loaders/full_path_model_loader.rb
View file @
37d2f721
...
...
@@ -5,19 +5,20 @@ module Gitlab
module
Loaders
# Suitable for use to find resources that expose `where_full_path_in`,
# such as Project, Group, Namespace
# full path is always converted to lowercase for case-insensitive results
class
FullPathModelLoader
attr_reader
:model_class
,
:full_path
def
initialize
(
model_class
,
full_path
)
@model_class
=
model_class
@full_path
=
full_path
@full_path
=
full_path
.
downcase
end
def
find
BatchLoader
::
GraphQL
.
for
(
full_path
).
batch
(
key:
model_class
)
do
|
full_paths
,
loader
,
args
|
# `with_route` avoids an N+1 calculating full_path
args
[
:key
].
where_full_path_in
(
full_paths
).
with_route
.
each
do
|
model_instance
|
loader
.
call
(
model_instance
.
full_path
,
model_instance
)
loader
.
call
(
model_instance
.
full_path
.
downcase
,
model_instance
)
end
end
end
...
...
spec/graphql/resolvers/group_resolver_spec.rb
View file @
37d2f721
...
...
@@ -20,10 +20,15 @@ RSpec.describe Resolvers::GroupResolver do
end
it
'resolves an unknown full_path to nil'
do
result
=
batch_sync
{
resolve_group
(
'unknown/
project
'
)
}
result
=
batch_sync
{
resolve_group
(
'unknown/
group
'
)
}
expect
(
result
).
to
be_nil
end
it
'treats group full path as case insensitive'
do
result
=
batch_sync
{
resolve_group
(
group1
.
full_path
.
upcase
)
}
expect
(
result
).
to
eq
group1
end
end
def
resolve_group
(
full_path
)
...
...
spec/graphql/resolvers/project_resolver_spec.rb
View file @
37d2f721
...
...
@@ -25,6 +25,11 @@ RSpec.describe Resolvers::ProjectResolver do
expect
(
result
).
to
be_nil
end
it
'treats project full path as case insensitive'
do
result
=
batch_sync
{
resolve_project
(
project1
.
full_path
.
upcase
)
}
expect
(
result
).
to
eq
project1
end
end
it
'does not increase complexity depending on number of load limits'
do
...
...
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