Commit d8af8dd1 authored by charlie ablett's avatar charlie ablett

Merge branch '220297-attempts-to-edit-issue-are-blocked-by-never-ending-captchas' into 'master'

Limit spam checks to title, description, or confidentiality changes on bot-created issues

See merge request gitlab-org/gitlab!43463
parents 17e608c8 96c32431
...@@ -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
......
---
title: Limit spam checks to title, description, or confidentiality changes on bot-created
issues
merge_request: 43463
author:
type: fixed
...@@ -346,6 +346,38 @@ RSpec.describe Issue do ...@@ -346,6 +346,38 @@ 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 }
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
Gitlab::VisibilityLevel::PRIVATE | true | { weight: 3 } | false
end
with_them do
context 'when author is a bot' do
it 'only checks for spam when description, title, or confidential status is updated' 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