Commit c141d0af authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch '56371-don-t-check-confidential-issues-for-spam' into 'master'

Resolve "Don't check confidential issues for spam"

Closes #56371

See merge request gitlab-org/gitlab-ce!24453
parents dc65a779 d00b4a2e
...@@ -230,7 +230,8 @@ class Issue < ActiveRecord::Base ...@@ -230,7 +230,8 @@ class Issue < ActiveRecord::Base
end end
def check_for_spam? def check_for_spam?
project.public? && (title_changed? || description_changed?) publicly_visible? &&
(title_changed? || description_changed? || confidential_changed?)
end end
def as_json(options = {}) def as_json(options = {})
......
---
title: Do not run spam checks on confidential issues
merge_request: 24453
author:
type: fixed
...@@ -721,39 +721,28 @@ describe Issue do ...@@ -721,39 +721,28 @@ describe Issue do
end end
end end
describe '#check_for_spam' do describe '#check_for_spam?' do
let(:project) { create :project, visibility_level: visibility_level } using RSpec::Parameterized::TableSyntax
let(:issue) { create :issue, project: project }
subject do where(:visibility_level, :confidential, :new_attributes, :check_for_spam?) do
issue.assign_attributes(description: description) Gitlab::VisibilityLevel::PUBLIC | false | { description: 'woo' } | true
issue.check_for_spam? Gitlab::VisibilityLevel::PUBLIC | false | { title: 'woo' } | true
Gitlab::VisibilityLevel::PUBLIC | true | { confidential: false } | true
Gitlab::VisibilityLevel::PUBLIC | true | { description: 'woo' } | false
Gitlab::VisibilityLevel::PUBLIC | false | { title: 'woo', confidential: true } | false
Gitlab::VisibilityLevel::PUBLIC | false | { description: 'original description' } | false
Gitlab::VisibilityLevel::INTERNAL | false | { description: 'woo' } | false
Gitlab::VisibilityLevel::PRIVATE | false | { description: 'woo' } | false
end end
context 'when project is public and spammable attributes changed' do with_them do
let(:visibility_level) { Gitlab::VisibilityLevel::PUBLIC } it 'checks for spam on issues that can be seen anonymously' do
let(:description) { 'woo' } project = create(:project, visibility_level: visibility_level)
issue = create(:issue, project: project, confidential: confidential, description: 'original description')
it 'returns true' do issue.assign_attributes(new_attributes)
is_expected.to be_truthy
end
end
context 'when project is private' do
let(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE }
let(:description) { issue.description }
it 'returns false' do
is_expected.to be_falsey
end
end
context 'when spammable attributes have not changed' do
let(:visibility_level) { Gitlab::VisibilityLevel::PUBLIC }
let(:description) { issue.description }
it 'returns false' do expect(issue.check_for_spam?).to eq(check_for_spam?)
is_expected.to be_falsey
end end
end end
end end
......
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