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
5de3c2ce
Commit
5de3c2ce
authored
Sep 21, 2020
by
Jake Lear
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test coverage for gitlab_bot?
parent
ed13a9f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
4 deletions
+41
-4
ee/spec/models/user_spec.rb
ee/spec/models/user_spec.rb
+41
-4
No files found.
ee/spec/models/user_spec.rb
View file @
5de3c2ce
...
@@ -1287,22 +1287,59 @@ RSpec.describe User do
...
@@ -1287,22 +1287,59 @@ RSpec.describe User do
end
end
describe
'#gitlab_bot?'
do
describe
'#gitlab_bot?'
do
using
RSpec
::
Parameterized
::
TableSyntax
subject
{
user
.
gitlab_bot?
}
subject
{
user
.
gitlab_bot?
}
let_it_be
(
:gitlab_group
)
{
create
(
:group
,
name:
'gitlab-com'
)
}
let_it_be
(
:gitlab_group
)
{
create
(
:group
,
name:
'gitlab-com'
)
}
let_it_be
(
:random_group
)
{
create
(
:group
,
name:
'random-group'
)
}
context
'based on
user type
'
do
context
'based on
group membership
'
do
context
'when user
is a bot
'
do
context
'when user
belongs to gitlab-com group
'
do
let
(
:user
)
{
build
(
:user
,
user_type: :alert_bot
)
}
let
(
:user
)
{
create
(
:user
,
user_type: :alert_bot
)
}
before
do
before
do
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
true
)
gitlab_group
.
add_user
(
user
,
Gitlab
::
Access
::
DEVELOPER
)
gitlab_group
.
add_user
(
user
,
Gitlab
::
Access
::
DEVELOPER
)
end
end
it
{
is_expected
.
to
be
true
}
it
{
is_expected
.
to
be
true
}
end
end
context
'when user does not belongs to gitlab-com group'
do
let
(
:user
)
{
create
(
:user
,
user_type: :alert_bot
)
}
before
do
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
true
)
random_group
.
add_user
(
user
,
Gitlab
::
Access
::
DEVELOPER
)
end
it
{
is_expected
.
to
be
false
}
end
end
context
'based on user type'
do
before
do
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
true
)
gitlab_group
.
add_user
(
user
,
Gitlab
::
Access
::
DEVELOPER
)
end
context
'when user is a bot'
do
let
(
:user
)
{
create
(
:user
,
user_type: :alert_bot
)
}
it
{
is_expected
.
to
be
true
}
end
context
'when user is a human'
do
let
(
:user
)
{
create
(
:user
,
user_type: :human
)
}
it
{
is_expected
.
to
be
false
}
end
context
'when user is ghost'
do
let
(
:user
)
{
create
(
:user
,
:ghost
)
}
it
{
is_expected
.
to
be
false
}
end
end
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