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
5122c47b
Commit
5122c47b
authored
Aug 05, 2021
by
Alex Pooley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing traversal hierarchy_order specs
parent
923d0a26
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
5 deletions
+81
-5
spec/support/shared_examples/namespaces/traversal_examples.rb
.../support/shared_examples/namespaces/traversal_examples.rb
+81
-5
No files found.
spec/support/shared_examples/namespaces/traversal_examples.rb
View file @
5122c47b
...
...
@@ -55,12 +55,34 @@ RSpec.shared_examples 'namespace traversal' do
end
describe
'#ancestors'
do
it
'returns the correct ancestors'
do
before
do
# #reload is called to make sure traversal_ids are reloaded
expect
(
very_deep_nested_group
.
reload
.
ancestors
).
to
contain_exactly
(
group
,
nested_group
,
deep_nested_group
)
expect
(
deep_nested_group
.
reload
.
ancestors
).
to
contain_exactly
(
group
,
nested_group
)
expect
(
nested_group
.
reload
.
ancestors
).
to
contain_exactly
(
group
)
expect
(
group
.
reload
.
ancestors
).
to
eq
([])
reload_models
(
group
,
nested_group
,
deep_nested_group
,
very_deep_nested_group
)
end
it
'returns the correct ancestors'
do
expect
(
very_deep_nested_group
.
ancestors
).
to
contain_exactly
(
group
,
nested_group
,
deep_nested_group
)
expect
(
deep_nested_group
.
ancestors
).
to
contain_exactly
(
group
,
nested_group
)
expect
(
nested_group
.
ancestors
).
to
contain_exactly
(
group
)
expect
(
group
.
ancestors
).
to
eq
([])
end
context
'with asc hierarchy_order'
do
it
'returns the correct ancestors'
do
expect
(
very_deep_nested_group
.
ancestors
(
hierarchy_order: :asc
)).
to
eq
[
deep_nested_group
,
nested_group
,
group
]
expect
(
deep_nested_group
.
ancestors
(
hierarchy_order: :asc
)).
to
eq
[
nested_group
,
group
]
expect
(
nested_group
.
ancestors
(
hierarchy_order: :asc
)).
to
eq
[
group
]
expect
(
group
.
ancestors
(
hierarchy_order: :asc
)).
to
eq
([])
end
end
context
'with desc hierarchy_order'
do
it
'returns the correct ancestors'
do
expect
(
very_deep_nested_group
.
ancestors
(
hierarchy_order: :desc
)).
to
eq
[
group
,
nested_group
,
deep_nested_group
]
expect
(
deep_nested_group
.
ancestors
(
hierarchy_order: :desc
)).
to
eq
[
group
,
nested_group
]
expect
(
nested_group
.
ancestors
(
hierarchy_order: :desc
)).
to
eq
[
group
]
expect
(
group
.
ancestors
(
hierarchy_order: :desc
)).
to
eq
([])
end
end
describe
'#recursive_ancestors'
do
...
...
@@ -78,6 +100,24 @@ RSpec.shared_examples 'namespace traversal' do
expect
(
group
.
ancestor_ids
).
to
be_empty
end
context
'with asc hierarchy_order'
do
it
'returns the correct ancestor ids'
do
expect
(
very_deep_nested_group
.
ancestor_ids
(
hierarchy_order: :asc
)).
to
eq
[
deep_nested_group
.
id
,
nested_group
.
id
,
group
.
id
]
expect
(
deep_nested_group
.
ancestor_ids
(
hierarchy_order: :asc
)).
to
eq
[
nested_group
.
id
,
group
.
id
]
expect
(
nested_group
.
ancestor_ids
(
hierarchy_order: :asc
)).
to
eq
[
group
.
id
]
expect
(
group
.
ancestor_ids
(
hierarchy_order: :asc
)).
to
eq
([])
end
end
context
'with desc hierarchy_order'
do
it
'returns the correct ancestor ids'
do
expect
(
very_deep_nested_group
.
ancestor_ids
(
hierarchy_order: :desc
)).
to
eq
[
group
.
id
,
nested_group
.
id
,
deep_nested_group
.
id
]
expect
(
deep_nested_group
.
ancestor_ids
(
hierarchy_order: :desc
)).
to
eq
[
group
.
id
,
nested_group
.
id
]
expect
(
nested_group
.
ancestor_ids
(
hierarchy_order: :desc
)).
to
eq
[
group
.
id
]
expect
(
group
.
ancestor_ids
(
hierarchy_order: :desc
)).
to
eq
([])
end
end
describe
'#recursive_ancestor_ids'
do
let_it_be
(
:groups
)
{
[
nested_group
,
deep_nested_group
,
very_deep_nested_group
]
}
...
...
@@ -93,6 +133,24 @@ RSpec.shared_examples 'namespace traversal' do
expect
(
group
.
self_and_ancestors
).
to
contain_exactly
(
group
)
end
context
'with asc hierarchy_order'
do
it
'returns the correct ancestors'
do
expect
(
very_deep_nested_group
.
self_and_ancestors
(
hierarchy_order: :asc
)).
to
eq
[
very_deep_nested_group
,
deep_nested_group
,
nested_group
,
group
]
expect
(
deep_nested_group
.
self_and_ancestors
(
hierarchy_order: :asc
)).
to
eq
[
deep_nested_group
,
nested_group
,
group
]
expect
(
nested_group
.
self_and_ancestors
(
hierarchy_order: :asc
)).
to
eq
[
nested_group
,
group
]
expect
(
group
.
self_and_ancestors
(
hierarchy_order: :asc
)).
to
eq
([
group
])
end
end
context
'with desc hierarchy_order'
do
it
'returns the correct ancestors'
do
expect
(
very_deep_nested_group
.
self_and_ancestors
(
hierarchy_order: :desc
)).
to
eq
[
group
,
nested_group
,
deep_nested_group
,
very_deep_nested_group
]
expect
(
deep_nested_group
.
self_and_ancestors
(
hierarchy_order: :desc
)).
to
eq
[
group
,
nested_group
,
deep_nested_group
]
expect
(
nested_group
.
self_and_ancestors
(
hierarchy_order: :desc
)).
to
eq
[
group
,
nested_group
]
expect
(
group
.
self_and_ancestors
(
hierarchy_order: :desc
)).
to
eq
([
group
])
end
end
describe
'#recursive_self_and_ancestors'
do
let_it_be
(
:groups
)
{
[
nested_group
,
deep_nested_group
,
very_deep_nested_group
]
}
...
...
@@ -108,6 +166,24 @@ RSpec.shared_examples 'namespace traversal' do
expect
(
group
.
self_and_ancestor_ids
).
to
contain_exactly
(
group
.
id
)
end
context
'with asc hierarchy_order'
do
it
'returns the correct ancestor ids'
do
expect
(
very_deep_nested_group
.
self_and_ancestor_ids
(
hierarchy_order: :asc
)).
to
eq
[
very_deep_nested_group
.
id
,
deep_nested_group
.
id
,
nested_group
.
id
,
group
.
id
]
expect
(
deep_nested_group
.
self_and_ancestor_ids
(
hierarchy_order: :asc
)).
to
eq
[
deep_nested_group
.
id
,
nested_group
.
id
,
group
.
id
]
expect
(
nested_group
.
self_and_ancestor_ids
(
hierarchy_order: :asc
)).
to
eq
[
nested_group
.
id
,
group
.
id
]
expect
(
group
.
self_and_ancestor_ids
(
hierarchy_order: :asc
)).
to
eq
([
group
.
id
])
end
end
context
'with desc hierarchy_order'
do
it
'returns the correct ancestor ids'
do
expect
(
very_deep_nested_group
.
self_and_ancestor_ids
(
hierarchy_order: :desc
)).
to
eq
[
group
.
id
,
nested_group
.
id
,
deep_nested_group
.
id
,
very_deep_nested_group
.
id
]
expect
(
deep_nested_group
.
self_and_ancestor_ids
(
hierarchy_order: :desc
)).
to
eq
[
group
.
id
,
nested_group
.
id
,
deep_nested_group
.
id
]
expect
(
nested_group
.
self_and_ancestor_ids
(
hierarchy_order: :desc
)).
to
eq
[
group
.
id
,
nested_group
.
id
]
expect
(
group
.
self_and_ancestor_ids
(
hierarchy_order: :desc
)).
to
eq
([
group
.
id
])
end
end
describe
'#recursive_self_and_ancestor_ids'
do
let_it_be
(
:groups
)
{
[
nested_group
,
deep_nested_group
,
very_deep_nested_group
]
}
...
...
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