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
ec00b3fb
Commit
ec00b3fb
authored
Oct 16, 2019
by
Michael Kozono
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'review-bot' into 'master'
Added Visual Review Bot See merge request gitlab-org/gitlab!18663
parents
1dc056b3
8ba11dfc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
2 deletions
+35
-2
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+11
-1
ee/app/policies/ee/base_policy.rb
ee/app/policies/ee/base_policy.rb
+3
-0
ee/app/policies/ee/policy_actor.rb
ee/app/policies/ee/policy_actor.rb
+4
-0
ee/app/policies/ee/project_policy.rb
ee/app/policies/ee/project_policy.rb
+6
-0
ee/spec/models/user_spec.rb
ee/spec/models/user_spec.rb
+3
-1
ee/spec/policies/project_policy_spec.rb
ee/spec/policies/project_policy_spec.rb
+8
-0
No files found.
ee/app/models/ee/user.rb
View file @
ec00b3fb
...
...
@@ -82,7 +82,8 @@ module EE
enum
bot_type:
{
support_bot:
1
,
alert_bot:
2
alert_bot:
2
,
visual_review_bot:
3
}
end
...
...
@@ -107,6 +108,15 @@ module EE
end
end
def
visual_review_bot
email_pattern
=
"visual_review%s@
#{
Settings
.
gitlab
.
host
}
"
unique_internal
(
where
(
bot_type: :visual_review_bot
),
'visual-review-bot'
,
email_pattern
)
do
|
u
|
u
.
bio
=
'The Gitlab Visual Review feedback bot'
u
.
name
=
'Gitlab Visual Review Bot'
end
end
override
:internal
def
internal
super
.
or
(
where
.
not
(
bot_type:
nil
))
...
...
ee/app/policies/ee/base_policy.rb
View file @
ec00b3fb
...
...
@@ -14,6 +14,9 @@ module EE
with_scope
:user
condition
(
:alert_bot
,
score:
0
)
{
@user
&
.
alert_bot?
}
with_scope
:user
condition
(
:visual_review_bot
,
score:
0
)
{
@user
&
.
visual_review_bot?
}
with_scope
:global
condition
(
:license_block
)
{
License
.
block_changes?
}
end
...
...
ee/app/policies/ee/policy_actor.rb
View file @
ec00b3fb
...
...
@@ -13,5 +13,9 @@ module EE
def
alert_bot?
false
end
def
visual_review_bot?
false
end
end
end
ee/app/policies/ee/project_policy.rb
View file @
ec00b3fb
...
...
@@ -102,6 +102,11 @@ module EE
prevent
:read_project
end
rule
{
visual_review_bot
}.
policy
do
prevent
:read_note
enable
:create_note
end
rule
{
license_block
}.
policy
do
prevent
:create_issue
prevent
:create_merge_request_in
...
...
@@ -287,6 +292,7 @@ module EE
return
::
Gitlab
::
Access
::
NO_ACCESS
if
needs_new_sso_session?
return
::
Gitlab
::
Access
::
REPORTER
if
alert_bot?
return
::
Gitlab
::
Access
::
GUEST
if
support_bot?
&&
service_desk_enabled?
return
::
Gitlab
::
Access
::
NO_ACCESS
if
visual_review_bot?
super
end
...
...
ee/spec/models/user_spec.rb
View file @
ec00b3fb
...
...
@@ -571,8 +571,9 @@ describe User do
let!
(
:ghost
)
{
described_class
.
ghost
}
let!
(
:support_bot
)
{
described_class
.
support_bot
}
let!
(
:alert_bot
)
{
described_class
.
alert_bot
}
let!
(
:visual_review_bot
)
{
described_class
.
visual_review_bot
}
let!
(
:non_internal
)
{
[
user
]
}
let!
(
:internal
)
{
[
ghost
,
support_bot
,
alert_bot
]
}
let!
(
:internal
)
{
[
ghost
,
support_bot
,
alert_bot
,
visual_review_bot
]
}
it
'returns non internal users'
do
expect
(
described_class
.
internal
).
to
eq
(
internal
)
...
...
@@ -591,6 +592,7 @@ describe User do
expect
(
support_bot
.
bot?
).
to
eq
(
true
)
expect
(
alert_bot
.
bot?
).
to
eq
(
true
)
expect
(
visual_review_bot
.
bot?
).
to
eq
(
true
)
end
end
end
...
...
ee/spec/policies/project_policy_spec.rb
View file @
ec00b3fb
...
...
@@ -980,6 +980,14 @@ describe ProjectPolicy do
end
end
context
'visual review bot'
do
let
(
:current_user
)
{
User
.
visual_review_bot
}
it
{
expect_allowed
(
:create_note
)
}
it
{
expect_disallowed
(
:read_note
)
}
it
{
expect_disallowed
(
:resolve_note
)
}
end
context
'commit_committer_check is not enabled by the current license'
do
before
do
stub_licensed_features
(
commit_committer_check:
false
)
...
...
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