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
dda10f5a
Commit
dda10f5a
authored
Jun 30, 2021
by
Jonathan Schafer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests
parent
abb677dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
17 deletions
+27
-17
spec/finders/projects_finder_spec.rb
spec/finders/projects_finder_spec.rb
+13
-13
spec/graphql/resolvers/projects_resolver_spec.rb
spec/graphql/resolvers/projects_resolver_spec.rb
+14
-4
No files found.
spec/finders/projects_finder_spec.rb
View file @
dda10f5a
...
...
@@ -364,28 +364,28 @@ RSpec.describe ProjectsFinder do
end
describe
'sorting'
do
let_it_be
(
:more_projects
)
do
[
create
(
:project
,
:internal
,
group:
group
,
name:
'projA'
,
path:
'projA'
),
create
(
:project
,
:internal
,
group:
group
,
name:
'projABC'
,
path:
'projABC'
),
create
(
:project
,
:internal
,
group:
group
,
name:
'projAB'
,
path:
'projAB'
)
]
end
context
'when sorting by a field'
do
let
(
:params
)
{
{
sort:
'name_asc'
}
}
it
{
is_expected
.
to
eq
(
[
internal_project
,
public_project
]
)
}
it
{
is_expected
.
to
eq
(
([
internal_project
,
public_project
]
+
more_projects
).
sort_by
{
|
p
|
p
[
:name
]
}
)
}
end
context
'when sorting by similarity'
do
let
(
:params
)
{
{
sort:
'similarity'
,
search:
'pro'
}
}
let_it_be
(
:internal_project2
)
do
create
(
:project
,
:internal
,
group:
group
,
name:
'projA'
,
path:
'projA'
)
end
let_it_be
(
:internal_project3
)
do
create
(
:project
,
:internal
,
group:
group
,
name:
'projABC'
,
path:
'projABC'
)
end
let_it_be
(
:internal_project4
)
do
create
(
:project
,
:internal
,
group:
group
,
name:
'projAB'
,
path:
'projAB'
)
end
it
{
is_expected
.
to
eq
([
more_projects
[
0
],
more_projects
[
2
],
more_projects
[
1
]])
}
end
it
{
is_expected
.
to
eq
([
internal_project2
,
internal_project4
,
internal_project3
])
}
context
'when no sort is provided'
do
it
{
is_expected
.
to
eq
(([
internal_project
,
public_project
]
+
more_projects
).
sort_by
{
|
p
|
p
[
:id
]
}.
reverse
)
}
end
end
...
...
spec/graphql/resolvers/projects_resolver_spec.rb
View file @
dda10f5a
...
...
@@ -79,6 +79,7 @@ RSpec.describe Resolvers::ProjectsResolver do
context
'when user is logged in'
do
let
(
:current_user
)
{
user
}
let
(
:visible_projecs
)
{
[
project
,
other_project
,
group_project
,
private_project
,
private_group_project
]
}
context
'when no filters are applied'
do
it
'returns all visible projects for the user'
do
...
...
@@ -125,15 +126,24 @@ RSpec.describe Resolvers::ProjectsResolver do
end
end
context
'when sort
is similarity
'
do
context
'when sort
ing
'
do
let_it_be
(
:named_project1
)
{
create
(
:project
,
:public
,
name:
'projAB'
,
path:
'projAB'
)
}
let_it_be
(
:named_project2
)
{
create
(
:project
,
:public
,
name:
'projABC'
,
path:
'projABC'
)
}
let_it_be
(
:named_project3
)
{
create
(
:project
,
:public
,
name:
'projA'
,
path:
'projA'
)
}
let_it_be
(
:named_projects
)
{
[
named_project1
,
named_project2
,
named_project3
]
}
let
(
:filters
)
{
{
search:
'projA'
,
sort:
'similarity'
}
}
context
'when sorting by similarity'
do
let
(
:filters
)
{
{
search:
'projA'
,
sort:
'similarity'
}
}
it
'returns projects in order of similarity to search'
do
is_expected
.
to
eq
([
named_project3
,
named_project1
,
named_project2
])
it
'returns projects in order of similarity to search'
do
is_expected
.
to
eq
([
named_project3
,
named_project1
,
named_project2
])
end
end
context
'when no sort is provided'
do
it
'returns projects in descending order by id'
do
is_expected
.
to
match_array
((
visible_projecs
+
named_projects
).
sort_by
{
|
p
|
p
[
:id
]}.
reverse
)
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