summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorPatricio Cano <suprnova32@gmail.com>2016-07-16 11:42:44 -0500
committerPatricio Cano <suprnova32@gmail.com>2016-07-26 15:17:41 -0500
commit9c34fafb8b728358a516a25120aa5f28567eae48 (patch)
tree0efbad37c6c907baee4eadf55e28b58c19923ce6 /spec/controllers
parent8a95f1f32cd5d93044f4b7b4c9b606267910df79 (diff)
downloadgitlab-ce-9c34fafb8b728358a516a25120aa5f28567eae48.tar.gz
Submit new issues created via the WebUI by non project members to Akismet for spam check.
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects/issues_controller_spec.rb31
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) }