Commit a2642f13 authored by Jake Lear's avatar Jake Lear

Limit spam check fields for bot authors

parent 78e64bf0
...@@ -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
......
...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment