diff options
| author | Douwe Maan <douwe@gitlab.com> | 2016-07-27 19:36:43 +0000 |
|---|---|---|
| committer | Douwe Maan <douwe@gitlab.com> | 2016-07-27 19:36:43 +0000 |
| commit | f6063baed4e19eed2c1dd7549ede0692f3250df8 (patch) | |
| tree | f9ffe0d6ac6efefe300b7ca4881e97426a3d39ab /spec/controllers | |
| parent | ce31fb48564d349875b8191c6db91936b8a094ec (diff) | |
| parent | f01fce7f4683e06e83d3f91d38ca5b749e27e7ec (diff) | |
| download | gitlab-ce-f6063baed4e19eed2c1dd7549ede0692f3250df8.tar.gz | |
Merge branch 'akismet-ui-check' into 'master'
Submit new issues created via the WebUI or API to Akismet for spam check on public projects.
## What does this MR do?
Submit new issues created via the WebUI by non project members to Akismet for spam check.
## Why was this MR needed?
Support for Akismet was added only to the API with !2266. This MR builds on that functionality to also check issues submitted via the WebUI for spam.
## What are the relevant issue numbers?
Related to:
- #5573
- #5932
- gitlab-com/infrastructure#14
- gitlab-com/support#61
- !2266
cc @stanhu @MrChrisW
See merge request !5333
Diffstat (limited to 'spec/controllers')
| -rw-r--r-- | spec/controllers/projects/issues_controller_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 7cf09fa4a4a..77f65057f71 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -243,6 +243,37 @@ describe Projects::IssuesController do end end + describe 'POST #create' do + context 'Akismet is enabled' do + before do + allow_any_instance_of(Gitlab::AkismetHelper).to receive(:check_for_spam?).and_return(true) + allow_any_instance_of(Gitlab::AkismetHelper).to receive(:is_spam?).and_return(true) + end + + def post_spam_issue + sign_in(user) + spam_project = create(:empty_project, :public) + post :create, { + namespace_id: spam_project.namespace.to_param, + project_id: spam_project.to_param, + issue: { title: 'Spam Title', description: 'Spam lives here' } + } + end + + it 'rejects an issue recognized as spam' do + expect{ post_spam_issue }.not_to change(Issue, :count) + expect(response).to render_template(:new) + end + + it 'creates a spam log' do + post_spam_issue + spam_logs = SpamLog.all + expect(spam_logs.count).to eq(1) + expect(spam_logs[0].title).to eq('Spam Title') + end + end + end + describe "DELETE #destroy" do context "when the user is a developer" do before { sign_in(user) } |
