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
325f520d
Commit
325f520d
authored
Dec 07, 2021
by
Ezekiel Kigbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for `namespaces_as_json`
Adds related rspec tests for the helper method `namespaces_as_json`
parent
f9263890
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
spec/helpers/namespaces_helper_spec.rb
spec/helpers/namespaces_helper_spec.rb
+33
-0
No files found.
spec/helpers/namespaces_helper_spec.rb
View file @
325f520d
...
...
@@ -45,6 +45,39 @@ RSpec.describe NamespacesHelper do
user_group
.
add_owner
(
user
)
end
describe
'#namespaces_as_json'
do
let
(
:result
)
{
helper
.
namespaces_as_json
(
user
)
}
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
end
it
'returns the user\'s groups'
do
json_data
=
Gitlab
::
Json
.
parse
(
result
)
expect
(
result
).
to
include
(
'group'
)
expect
(
json_data
[
'group'
]).
to
include
(
"id"
=>
user_group
.
id
,
"name"
=>
user_group
.
name
,
"display_path"
=>
user_group
.
full_path
,
"human_name"
=>
user_group
.
human_name
)
end
it
'returns the user\'s namespace'
do
user_namespace
=
user
.
namespace
json_data
=
Gitlab
::
Json
.
parse
(
result
)
expect
(
result
).
to
include
(
'user'
)
expect
(
json_data
[
'user'
]).
to
include
(
"id"
=>
user_namespace
.
id
,
"name"
=>
user_namespace
.
name
,
"display_path"
=>
user_namespace
.
full_path
,
"human_name"
=>
user_namespace
.
human_name
)
end
end
describe
'#namespaces_options'
do
context
'when admin mode is enabled'
,
:enable_admin_mode
do
it
'returns groups without being a member for admin'
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