summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-01-09 19:30:34 +0000
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-02-02 11:25:44 -0200
commitd20e75a8d80c2828336cd22897ea6868d666f8a5 (patch)
tree9cbf725ad1b523ab0c8d94261d4a02a0677ca450 /spec/requests
parent6cffcb05882b0d3c4a02f9acf21806e25ea09ec3 (diff)
downloadgitlab-ce-d20e75a8d80c2828336cd22897ea6868d666f8a5.tar.gz
Support Akismet spam checking for creation of issues via API
Currently any spam detected by Akismet by non-members via API will be logged in a separate table in the admin page. Closes #5612
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/issues_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index 5e65ad18c0e..2e50344c149 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -241,6 +241,28 @@ describe API::API, api: true do
end
end
+ describe 'POST /projects/:id/issues with spam filtering' do
+ before do
+ Grape::Endpoint.before_each do |endpoint|
+ allow(endpoint).to receive(:check_for_spam?).and_return(true)
+ allow(endpoint).to receive(:is_spam?).and_return(true)
+ end
+ end
+
+ it "should create a new project issue" do
+ post api("/projects/#{project.id}/issues", user),
+ title: 'new issue', labels: 'label, label2'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq({ "error" => "Spam detected" })
+ spam_logs = SpamLog.all
+ expect(spam_logs.count).to eq(1)
+ expect(spam_logs[0].title).to eq('new issue')
+ expect(spam_logs[0].user).to eq(user)
+ expect(spam_logs[0].noteable_type).to eq('Issue')
+ expect(spam_logs[0].project_id).to eq(project.id)
+ end
+ end
+
describe "PUT /projects/:id/issues/:issue_id to update only title" do
it "should update a project issue" do
put api("/projects/#{project.id}/issues/#{issue.id}", user),