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:
authorHoracio Bertorello <svankie@gmail.com>2017-06-27 23:43:02 +0300
committerHoracio Bertorello <svankie@gmail.com>2017-06-28 20:37:14 +0300
commit49957cf55114d75dc2c1e62c71a98aad98866960 (patch)
treed9db87da54e7313a3e0279a872b0fce58ff0c811 /spec/controllers
parentd3c3200ca967142944d89b725e7dcc660e8e601c (diff)
Fix errors caused by attempts to report already blocked or deleted users
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/abuse_reports_controller_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/controllers/abuse_reports_controller_spec.rb b/spec/controllers/abuse_reports_controller_spec.rb
index 80a418feb3e..ada011e7595 100644
--- a/spec/controllers/abuse_reports_controller_spec.rb
+++ b/spec/controllers/abuse_reports_controller_spec.rb
@@ -13,6 +13,31 @@ describe AbuseReportsController do
sign_in(reporter)
end
+ describe 'GET new' do
+ context 'when the user has already been deleted' do
+ it 'redirects the reporter to root_path' do
+ user_id = user.id
+ user.destroy
+
+ get :new, { user_id: user_id }
+
+ expect(response).to redirect_to root_path
+ expect(flash[:alert]).to eq('Cannot create the abuse report. The user has been deleted.')
+ end
+ end
+
+ context 'when the user has already been blocked' do
+ it 'redirects the reporter to the user\'s profile' do
+ user.block
+
+ get :new, { user_id: user.id }
+
+ expect(response).to redirect_to user
+ expect(flash[:alert]).to eq('Cannot create the abuse report. This user has been blocked.')
+ end
+ end
+ end
+
describe 'POST create' do
context 'with valid attributes' do
it 'saves the abuse report' do