summaryrefslogtreecommitdiff
path: root/spec/controllers
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/controllers
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/controllers')
-rw-r--r--spec/controllers/admin/spam_logs_controller_spec.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/controllers/admin/spam_logs_controller_spec.rb b/spec/controllers/admin/spam_logs_controller_spec.rb
new file mode 100644
index 00000000000..2486298fc78
--- /dev/null
+++ b/spec/controllers/admin/spam_logs_controller_spec.rb
@@ -0,0 +1,47 @@
+require 'spec_helper'
+
+describe Admin::SpamLogsController do
+ let(:admin) { create(:admin) }
+ let(:spam_log) { create(:spam_log, user: admin) }
+
+ before do
+ sign_in(admin)
+ end
+
+ describe '#index' do
+ it 'lists all spam logs' do
+ get :index
+ expect(response.status).to eq(200)
+ end
+ end
+
+ describe '#destroy' do
+ it 'destroys just spam log' do
+ user = spam_log.user
+ delete :destroy, id: spam_log.id
+
+ expect(SpamLog.all.count).to eq(0)
+ expect(User.find(user.id)).to be_truthy
+ expect(response.status).to eq(302)
+ end
+
+ it 'destroys user and his spam logs' do
+ user = spam_log.user
+ delete :destroy, id: spam_log.id, remove_user: true
+
+ expect(SpamLog.all.count).to eq(0)
+ expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
+ expect(response.status).to eq(302)
+ end
+
+ it 'destroys user and his spam logs with JSON format' do
+ user = spam_log.user
+ delete :destroy, id: spam_log.id, remove_user: true, format: :json
+
+ expect(SpamLog.all.count).to eq(0)
+ expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
+ expect(JSON.parse(response.body)).to eq({})
+ expect(response.status).to eq(200)
+ end
+ end
+end