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
85bcc222
Commit
85bcc222
authored
Mar 08, 2022
by
Valerie Burton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use traversal_ids instead of path for ordering
parent
fcc24a29
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
10 deletions
+30
-10
spec/support/shared_examples/namespaces/traversal_scope_examples.rb
...rt/shared_examples/namespaces/traversal_scope_examples.rb
+30
-10
No files found.
spec/support/shared_examples/namespaces/traversal_scope_examples.rb
View file @
85bcc222
...
...
@@ -2,14 +2,14 @@
RSpec
.
shared_examples
'namespace traversal scopes'
do
# Hierarchy 1
let_it_be
(
:group_1
)
{
create
(
:group
,
path:
'group-1'
)
}
let_it_be
(
:nested_group_1
)
{
create
(
:group
,
pa
th:
'nested-group-1'
,
pa
rent:
group_1
)
}
let_it_be
(
:deep_nested_group_1
)
{
create
(
:group
,
pa
th:
'deep-nested-group-1'
,
pa
rent:
nested_group_1
)
}
let_it_be
(
:group_1
)
{
create
(
:group
)
}
let_it_be
(
:nested_group_1
)
{
create
(
:group
,
parent:
group_1
)
}
let_it_be
(
:deep_nested_group_1
)
{
create
(
:group
,
parent:
nested_group_1
)
}
# Hierarchy 2
let_it_be
(
:group_2
)
{
create
(
:group
,
path:
'group-2'
)
}
let_it_be
(
:nested_group_2
)
{
create
(
:group
,
pa
th:
'nested-group-2'
,
pa
rent:
group_2
)
}
let_it_be
(
:deep_nested_group_2
)
{
create
(
:group
,
pa
th:
'deep-nested-group-2'
,
pa
rent:
nested_group_2
)
}
let_it_be
(
:group_2
)
{
create
(
:group
)
}
let_it_be
(
:nested_group_2
)
{
create
(
:group
,
parent:
group_2
)
}
let_it_be
(
:deep_nested_group_2
)
{
create
(
:group
,
parent:
nested_group_2
)
}
# All groups
let_it_be
(
:groups
)
do
...
...
@@ -126,7 +126,12 @@ RSpec.shared_examples 'namespace traversal scopes' do
end
context
'with offset and limit'
do
subject
{
described_class
.
where
(
id:
[
deep_nested_group_1
,
deep_nested_group_2
]).
order
(
:path
).
offset
(
1
).
limit
(
1
).
self_and_ancestors
}
subject
{
described_class
.
where
(
id:
[
deep_nested_group_1
,
deep_nested_group_2
]).
order
(
:traversal_ids
).
offset
(
1
).
limit
(
1
).
self_and_ancestors
}
before
do
deep_nested_group_1
.
reload
deep_nested_group_2
.
reload
end
it
{
is_expected
.
to
contain_exactly
(
group_2
,
nested_group_2
,
deep_nested_group_2
)
}
end
...
...
@@ -185,13 +190,18 @@ RSpec.shared_examples 'namespace traversal scopes' do
subject
do
described_class
.
where
(
id:
[
deep_nested_group_1
,
deep_nested_group_2
])
.
order
(
:
path
)
.
order
(
:
traversal_ids
)
.
limit
(
1
)
.
offset
(
1
)
.
self_and_ancestor_ids
.
pluck
(
:id
)
end
before
do
deep_nested_group_1
.
reload
deep_nested_group_2
.
reload
end
it
{
is_expected
.
to
contain_exactly
(
group_2
.
id
,
nested_group_2
.
id
,
deep_nested_group_2
.
id
)
}
end
end
...
...
@@ -241,7 +251,12 @@ RSpec.shared_examples 'namespace traversal scopes' do
end
context
'with offset and limit'
do
subject
{
described_class
.
where
(
id:
[
group_1
,
group_2
]).
order
(
:path
).
offset
(
1
).
limit
(
1
).
self_and_descendants
}
subject
{
described_class
.
where
(
id:
[
group_1
,
group_2
]).
order
(
:traversal_ids
).
offset
(
1
).
limit
(
1
).
self_and_descendants
}
before
do
group_1
.
reload
group_2
.
reload
end
it
{
is_expected
.
to
contain_exactly
(
group_2
,
nested_group_2
,
deep_nested_group_2
)
}
end
...
...
@@ -289,13 +304,18 @@ RSpec.shared_examples 'namespace traversal scopes' do
subject
do
described_class
.
where
(
id:
[
group_1
,
group_2
])
.
order
(
:
path
)
.
order
(
:
traversal_ids
)
.
limit
(
1
)
.
offset
(
1
)
.
self_and_descendant_ids
.
pluck
(
:id
)
end
before
do
group_1
.
reload
group_2
.
reload
end
it
{
is_expected
.
to
contain_exactly
(
group_2
.
id
,
nested_group_2
.
id
,
deep_nested_group_2
.
id
)
}
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