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
14b4120f
Commit
14b4120f
authored
Feb 28, 2022
by
Serena Fang
Committed by
Douglas Barbosa Alexandre
Mar 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for group token name
Add specs to user_spec and user_type_spec
parent
7fa72910
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
0 deletions
+112
-0
spec/graphql/types/user_type_spec.rb
spec/graphql/types/user_type_spec.rb
+55
-0
spec/lib/api/entities/user_spec.rb
spec/lib/api/entities/user_spec.rb
+57
-0
No files found.
spec/graphql/types/user_type_spec.rb
View file @
14b4120f
...
...
@@ -52,10 +52,13 @@ RSpec.describe GitlabSchema.types['User'] do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:requested_user
)
{
create
(
:user
,
name:
'John Smith'
)
}
let_it_be
(
:requested_project_bot
)
{
create
(
:user
,
:project_bot
,
name:
'Project bot'
)
}
let_it_be
(
:requested_group_bot
)
{
create
(
:user
,
:project_bot
,
name:
'Group bot'
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:public
)
}
let_it_be
(
:group
)
{
create
(
:group
,
:public
)
}
before
do
project
.
add_maintainer
(
requested_project_bot
)
group
.
add_maintainer
(
requested_group_bot
)
end
let
(
:username
)
{
requested_user
.
username
}
...
...
@@ -123,6 +126,50 @@ RSpec.describe GitlabSchema.types['User'] do
end
end
end
context
'a group bot'
do
let
(
:username
)
{
requested_group_bot
.
username
}
context
'when requester is nil'
do
let
(
:current_user
)
{
nil
}
it
'returns `****`'
do
expect
(
user_name
).
to
eq
(
'****'
)
end
end
context
'when the requester is not a group member'
do
it
'returns `Group bot` for a non group member in a public group'
do
expect
(
user_name
).
to
eq
(
'Group bot'
)
end
context
'in a private group'
do
let
(
:group
)
{
create
(
:group
,
:private
)
}
it
'returns `****` for a non group member in a private group'
do
expect
(
user_name
).
to
eq
(
'****'
)
end
end
end
context
'with a group member'
do
before
do
group
.
add_guest
(
user
)
end
it
'returns `Group bot` for a group member'
do
expect
(
user_name
).
to
eq
(
'Group bot'
)
end
context
'in a private group'
do
let
(
:group
)
{
create
(
:group
,
:private
)
}
it
'returns `Group bot` for a group member in a private group'
do
expect
(
user_name
).
to
eq
(
'Group bot'
)
end
end
end
end
end
end
...
...
@@ -142,6 +189,14 @@ RSpec.describe GitlabSchema.types['User'] do
expect
(
subject
).
to
eq
(
'Project bot'
)
end
end
context
'a group bot'
do
let
(
:username
)
{
requested_group_bot
.
username
}
it
'returns name'
do
expect
(
subject
).
to
eq
(
'Group bot'
)
end
end
end
end
...
...
spec/lib/api/entities/user_spec.rb
View file @
14b4120f
...
...
@@ -78,6 +78,63 @@ RSpec.describe API::Entities::User do
end
end
context
'with group bot user'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:user
)
{
create
(
:user
,
:project_bot
,
name:
'group bot'
)
}
before
do
group
.
add_maintainer
(
user
)
end
it
'exposes user as a bot'
do
expect
(
subject
[
:bot
]).
to
eq
(
true
)
end
context
'when the requester is not a group member'
do
context
'with a public group'
do
it
'exposes group bot user name'
do
expect
(
subject
[
:name
]).
to
eq
(
'group bot'
)
end
end
context
'with a private group'
do
let
(
:group
)
{
create
(
:group
,
:private
)
}
it
'does not expose group bot user name'
do
expect
(
subject
[
:name
]).
to
eq
(
'****'
)
end
end
end
context
'when the requester is nil'
do
let
(
:current_user
)
{
nil
}
it
'does not expose group bot user name'
do
expect
(
subject
[
:name
]).
to
eq
(
'****'
)
end
end
context
'when the requester is a group maintainer'
do
let
(
:current_user
)
{
create
(
:user
)
}
before
do
group
.
add_maintainer
(
current_user
)
end
it
'exposes group bot user name'
do
expect
(
subject
[
:name
]).
to
eq
(
'group bot'
)
end
end
context
'when the requester is an admin'
do
let
(
:current_user
)
{
create
(
:user
,
:admin
)
}
it
'exposes group bot user name'
,
:enable_admin_mode
do
expect
(
subject
[
:name
]).
to
eq
(
'group bot'
)
end
end
end
it
'exposes local_time'
do
local_time
=
'2:30 PM'
expect
(
entity
).
to
receive
(
:local_time
).
with
(
timezone
).
and_return
(
local_time
)
...
...
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