Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Rochkind <jonathan@dnil.net>2015-10-08 18:13:28 +0300
committerJonathan Rochkind <jonathan@dnil.net>2015-10-09 00:33:57 +0300
commitae4fbae26cefbf10848719ee8c06d418c348420c (patch)
tree147370c32c20f1c78b0e078e442b4c7ba5bf1001 /spec/controllers/abuse_reports_controller_spec.rb
parent0de7c83a78711601b40b5a739070da2e3af29b11 (diff)
Send an email (to support) when a user is reported for spam
Diffstat (limited to 'spec/controllers/abuse_reports_controller_spec.rb')
-rw-r--r--spec/controllers/abuse_reports_controller_spec.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/controllers/abuse_reports_controller_spec.rb b/spec/controllers/abuse_reports_controller_spec.rb
new file mode 100644
index 00000000000..6d157406a2b
--- /dev/null
+++ b/spec/controllers/abuse_reports_controller_spec.rb
@@ -0,0 +1,53 @@
+require 'spec_helper'
+
+describe AbuseReportsController do
+ let(:reporter) { create(:user) }
+ let(:user) { create(:user) }
+ let(:message) { "This user is a spammer" }
+
+ before do
+ sign_in(reporter)
+ end
+
+ describe "with admin notification_email set" do
+ let(:admin_email) { "admin@example.com"}
+ before(:example) { allow(current_application_settings).to receive(:admin_notification_email).and_return(admin_email) }
+
+ it "sends a notification email" do
+ post(:create,
+ abuse_report: {
+ user_id: user.id,
+ message: message
+ }
+ )
+
+ expect(response).to have_http_status(:redirect)
+ expect(flash[:notice]).to start_with("Thank you for your report")
+
+ email = ActionMailer::Base.deliveries.last
+
+ expect(email).to be_present
+ expect(email.subject).to eq("[Gitlab] Abuse report filed for `#{user.username}`")
+ expect(email.to).to eq([admin_email])
+ expect(email.body).to include(message)
+ end
+ end
+
+ describe "without admin notification email set" do
+ before(:example) { allow(current_application_settings).to receive(:admin_notification_email).and_return(nil) }
+
+ it "does not send a notification email" do
+ expect do
+ post(:create,
+ abuse_report: {
+ user_id: user.id,
+ message: message
+ }
+ )
+ end.to_not change{ActionMailer::Base.deliveries}
+
+ expect(response).to have_http_status(:redirect)
+ expect(flash[:notice]).to start_with("Thank you for your report")
+ end
+ end
+end \ No newline at end of file