summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorPatricio Cano <suprnova32@gmail.com>2016-08-02 16:21:57 -0500
committerPatricio Cano <suprnova32@gmail.com>2016-08-15 13:18:15 -0500
commit96399a81cbb2e8a0f666241eeaff7cc784c26983 (patch)
tree7123e352717a846300c031cb884028fbd0a7f1d3 /spec/controllers
parentabf2dcd25c4a176801314872733ede91297d1ab0 (diff)
downloadgitlab-ce-96399a81cbb2e8a0f666241eeaff7cc784c26983.tar.gz
Allow `Issue` to be submitted as spam
- Added controller actions as reusable concerns - Added controller tests
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/admin/spam_logs_controller_spec.rb12
-rw-r--r--spec/controllers/projects/issues_controller_spec.rb29
2 files changed, 41 insertions, 0 deletions
diff --git a/spec/controllers/admin/spam_logs_controller_spec.rb b/spec/controllers/admin/spam_logs_controller_spec.rb
index 520a4f6f9c5..f94afd1139d 100644
--- a/spec/controllers/admin/spam_logs_controller_spec.rb
+++ b/spec/controllers/admin/spam_logs_controller_spec.rb
@@ -34,4 +34,16 @@ describe Admin::SpamLogsController do
expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
end
+
+ describe '#mark_as_ham' do
+ before do
+ allow_any_instance_of(Gitlab::AkismetHelper).to receive(:ham!).and_return(true)
+ end
+ it 'submits the log as ham' do
+ post :mark_as_ham, id: first_spam.id
+
+ expect(response).to have_http_status(302)
+ expect(SpamLog.find(first_spam.id).submitted_as_ham).to be_truthy
+ end
+ end
end
diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb
index efca838613f..8fcde9a38bc 100644
--- a/spec/controllers/projects/issues_controller_spec.rb
+++ b/spec/controllers/projects/issues_controller_spec.rb
@@ -322,6 +322,35 @@ describe Projects::IssuesController do
end
end
+ describe 'POST #mark_as_spam' do
+ context 'properly submits to Akismet' do
+ before do
+ allow_any_instance_of(Spammable).to receive_messages(can_be_submitted?: true, submit_spam: true)
+ end
+
+ def post_spam
+ admin = create(:admin)
+ create(:user_agent_detail, subject: issue)
+ project.team << [admin, :master]
+ sign_in(admin)
+ post :mark_as_spam, {
+ namespace_id: project.namespace.path,
+ project_id: project.path,
+ id: issue.iid
+ }
+ end
+
+ it 'creates a system note' do
+ expect{ post_spam }.to change(Note, :count)
+ end
+
+ it 'updates issue' do
+ post_spam
+ expect(issue.submitted?).to be_truthy
+ end
+ end
+ end
+
describe "DELETE #destroy" do
context "when the user is a developer" do
before { sign_in(user) }