Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
49957cf5
Commit
49957cf5
authored
Jun 27, 2017
by
Horacio Bertorello
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix errors caused by attempts to report already blocked or deleted users
parent
d3c3200c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
2 deletions
+43
-2
app/controllers/abuse_reports_controller.rb
app/controllers/abuse_reports_controller.rb
+13
-1
changelogs/unreleased/hb-fix-abuse-report-on-stale-user-profile.yml
.../unreleased/hb-fix-abuse-report-on-stale-user-profile.yml
+4
-0
spec/controllers/abuse_reports_controller_spec.rb
spec/controllers/abuse_reports_controller_spec.rb
+25
-0
spec/features/abuse_report_spec.rb
spec/features/abuse_report_spec.rb
+1
-1
No files found.
app/controllers/abuse_reports_controller.rb
View file @
49957cf5
class
AbuseReportsController
<
ApplicationController
class
AbuseReportsController
<
ApplicationController
before_action
:set_user
,
only:
[
:new
]
def
new
def
new
@abuse_report
=
AbuseReport
.
new
@abuse_report
=
AbuseReport
.
new
@abuse_report
.
user_id
=
params
[
:user_id
]
@abuse_report
.
user_id
=
@user
.
id
@ref_url
=
params
.
fetch
(
:ref_url
,
''
)
@ref_url
=
params
.
fetch
(
:ref_url
,
''
)
end
end
...
@@ -27,4 +29,14 @@ class AbuseReportsController < ApplicationController
...
@@ -27,4 +29,14 @@ class AbuseReportsController < ApplicationController
user_id
user_id
)
)
)
)
end
end
def
set_user
@user
=
User
.
find_by
(
id:
params
[
:user_id
])
if
@user
.
nil?
redirect_to
root_path
,
alert:
"Cannot create the abuse report. The user has been deleted."
elsif
@user
.
blocked?
redirect_to
@user
,
alert:
"Cannot create the abuse report. This user has been blocked."
end
end
end
end
changelogs/unreleased/hb-fix-abuse-report-on-stale-user-profile.yml
0 → 100644
View file @
49957cf5
---
title
:
Fix errors caused by attempts to report already blocked or deleted users
merge_request
:
12502
author
:
Horacio Bertorello
spec/controllers/abuse_reports_controller_spec.rb
View file @
49957cf5
...
@@ -13,6 +13,31 @@ describe AbuseReportsController do
...
@@ -13,6 +13,31 @@ describe AbuseReportsController do
sign_in
(
reporter
)
sign_in
(
reporter
)
end
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
describe
'POST create'
do
context
'with valid attributes'
do
context
'with valid attributes'
do
it
'saves the abuse report'
do
it
'saves the abuse report'
do
...
...
spec/features/abuse_report_spec.rb
View file @
49957cf5
...
@@ -12,7 +12,7 @@ feature 'Abuse reports', feature: true do
...
@@ -12,7 +12,7 @@ feature 'Abuse reports', feature: true do
click_link
'Report abuse'
click_link
'Report abuse'
fill_in
'abuse_report_message'
,
with:
'This user send spam'
fill_in
'abuse_report_message'
,
with:
'This user send
s
spam'
click_button
'Send report'
click_button
'Send report'
expect
(
page
).
to
have_content
'Thank you for your report'
expect
(
page
).
to
have_content
'Thank you for your report'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment