diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-06-29 16:23:09 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-06-29 16:23:09 +0300 |
commit | 0f5e70a8246de623ddafdc17c5d9ea5cb866b21a (patch) | |
tree | acae90f5a578e30d18a782da60304f3d22b28e32 /spec/controllers | |
parent | 8c5538be40b527ad8b5e3468730b84416ec536c1 (diff) | |
parent | 49957cf55114d75dc2c1e62c71a98aad98866960 (diff) |
Merge branch 'hb-fix-abuse-report-on-stale-user-profile' into 'master'
Fix errors caused by attempts to report already blocked or deleted users
Closes #8928
See merge request !12502
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/abuse_reports_controller_spec.rb | 25 |
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 |