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
a2642f13
Commit
a2642f13
authored
Sep 24, 2020
by
Jake Lear
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Limit spam check fields for bot authors
parent
78e64bf0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
1 deletion
+43
-1
ee/app/models/ee/issue.rb
ee/app/models/ee/issue.rb
+1
-1
ee/spec/models/issue_spec.rb
ee/spec/models/issue_spec.rb
+42
-0
No files found.
ee/app/models/ee/issue.rb
View file @
a2642f13
...
@@ -70,7 +70,7 @@ module EE
...
@@ -70,7 +70,7 @@ module EE
# override
# override
def
check_for_spam?
def
check_for_spam?
author
.
bot?
||
super
author
.
bot?
&&
(
title_changed?
||
description_changed?
||
confidential_changed?
)
||
super
end
end
# override
# override
...
...
ee/spec/models/issue_spec.rb
View file @
a2642f13
...
@@ -346,6 +346,48 @@ RSpec.describe Issue do
...
@@ -346,6 +346,48 @@ RSpec.describe Issue do
end
end
end
end
describe
'#check_for_spam?'
do
using
RSpec
::
Parameterized
::
TableSyntax
let_it_be
(
:reusable_project
)
{
create
(
:project
)
}
let_it_be
(
:author
)
{
::
User
.
support_bot
}
let
(
:planning
)
{
create
(
:project_label
,
project:
reusable_project
,
name:
'Planning'
)
}
where
(
:visibility_level
,
:confidential
,
:new_attributes
,
:check_for_spam?
)
do
Gitlab
::
VisibilityLevel
::
PUBLIC
|
false
|
{
description:
'woo'
}
|
true
Gitlab
::
VisibilityLevel
::
PUBLIC
|
false
|
{
title:
'woo'
}
|
true
Gitlab
::
VisibilityLevel
::
PUBLIC
|
true
|
{
confidential:
false
}
|
true
Gitlab
::
VisibilityLevel
::
PUBLIC
|
true
|
{
description:
'woo'
}
|
true
Gitlab
::
VisibilityLevel
::
PUBLIC
|
false
|
{
title:
'woo'
,
confidential:
true
}
|
true
Gitlab
::
VisibilityLevel
::
INTERNAL
|
false
|
{
description:
'woo'
}
|
true
Gitlab
::
VisibilityLevel
::
PRIVATE
|
true
|
{
description:
'woo'
}
|
true
Gitlab
::
VisibilityLevel
::
PUBLIC
|
false
|
{
description:
'original description'
}
|
false
end
with_them
do
context
'when author is a bot'
do
it
'checks for spam on all issues'
,
:focus
=>
true
do
project
=
reusable_project
project
.
update
(
visibility_level:
visibility_level
)
issue
=
create
(
:issue
,
project:
project
,
confidential:
confidential
,
description:
'original description'
,
author:
author
)
issue
.
assign_attributes
(
new_attributes
)
expect
(
issue
.
check_for_spam?
).
to
eq
(
check_for_spam?
)
end
it
'does not check for spam when milestone is updated'
,
:focus
=>
true
do
project
=
reusable_project
project
.
update
(
visibility_level:
visibility_level
)
issue
=
create
(
:issue
,
project:
project
,
confidential:
confidential
,
description:
'original description'
,
author:
author
)
issue
.
assign_attributes
(
new_attributes
)
expect
(
issue
.
check_for_spam?
).
to
eq
(
check_for_spam?
)
end
end
end
end
describe
'#weight'
do
describe
'#weight'
do
where
(
:license_value
,
:database_value
,
:expected
)
do
where
(
:license_value
,
:database_value
,
:expected
)
do
true
|
5
|
5
true
|
5
|
5
...
...
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