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
iv
gitlab-ce
Commits
5f95a5e0
Commit
5f95a5e0
authored
Sep 28, 2015
by
Rémy Coutable
Committed by
rymai
Sep 29, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable the "Report abuse" button if a user has already been reported
parent
10c036fc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
73 additions
and
9 deletions
+73
-9
app/helpers/user_helper.rb
app/helpers/user_helper.rb
+11
-0
app/models/user.rb
app/models/user.rb
+2
-0
app/views/users/show.html.haml
app/views/users/show.html.haml
+11
-7
features/abuse_report.feature
features/abuse_report.feature
+7
-0
features/steps/abuse_reports.rb
features/steps/abuse_reports.rb
+5
-0
spec/features/users_spec.rb
spec/features/users_spec.rb
+36
-2
spec/models/user_spec.rb
spec/models/user_spec.rb
+1
-0
No files found.
app/helpers/user_helper.rb
0 → 100644
View file @
5f95a5e0
module
UserHelper
def
abuse_report_button_title
(
user
)
if
user
.
abuse_report
"
#{
user
.
username
}
has already been reported for abuse."
else
"Report
#{
user
.
username
}
for abuse."
end
end
end
app/models/user.rb
View file @
5f95a5e0
...
@@ -97,7 +97,9 @@ class User < ActiveRecord::Base
...
@@ -97,7 +97,9 @@ class User < ActiveRecord::Base
# Namespace for personal projects
# Namespace for personal projects
has_one
:namespace
,
->
{
where
type:
nil
},
dependent: :destroy
,
foreign_key: :owner_id
,
class_name:
"Namespace"
has_one
:namespace
,
->
{
where
type:
nil
},
dependent: :destroy
,
foreign_key: :owner_id
,
class_name:
"Namespace"
# Profile
# Profile
has_one
:abuse_report
,
dependent: :destroy
has_many
:keys
,
dependent: :destroy
has_many
:keys
,
dependent: :destroy
has_many
:emails
,
dependent: :destroy
has_many
:emails
,
dependent: :destroy
has_many
:identities
,
dependent: :destroy
,
autosave:
true
has_many
:identities
,
dependent: :destroy
,
autosave:
true
...
...
app/views/users/show.html.haml
View file @
5f95a5e0
...
@@ -19,14 +19,18 @@
...
@@ -19,14 +19,18 @@
=
icon
(
'user'
)
=
icon
(
'user'
)
Profile settings
Profile settings
-
elsif
current_user
-
elsif
current_user
.pull-right
#report_abuse
.pull-right
%span
.dropdown
%span
.dropdown
%a
.light.dropdown-toggle.btn.btn-sm
{
href:
'#'
,
"data-toggle"
=>
"dropdown"
}
-
if
@user
.
abuse_report
=
icon
(
'exclamation-circle'
)
%span
.light.dropdown-toggle.btn.btn-sm.btn-close
{
title:
abuse_report_button_title
(
@user
)}
%ul
.dropdown-menu.dropdown-menu-right
=
icon
(
'exclamation-circle'
)
%li
-
else
=
link_to
new_abuse_report_path
(
user_id:
@user
.
id
)
do
%a
.light.dropdown-toggle.btn.btn-sm
{
href:
'#'
,
"data-toggle"
=>
"dropdown"
}
Report abuse
=
icon
(
'exclamation-circle'
)
%ul
.dropdown-menu.dropdown-menu-right
%li
=
link_to
new_abuse_report_path
(
user_id:
@user
.
id
),
title:
abuse_report_button_title
(
@user
)
do
Report abuse
.username
.username
@
#{
@user
.
username
}
@
#{
@user
.
username
}
...
...
features/abuse_report.feature
View file @
5f95a5e0
...
@@ -8,3 +8,10 @@ Feature: Abuse reports
...
@@ -8,3 +8,10 @@ Feature: Abuse reports
And
I click
"Report abuse"
button
And
I click
"Report abuse"
button
When
I fill and submit abuse form
When
I fill and submit abuse form
Then
I should see success message
Then
I should see success message
Scenario
:
Report abuse available only once
Given
I visit
"Mike"
user page
And
I click
"Report abuse"
button
When
I fill and submit abuse form
And
I visit
"Mike"
user page
Then
I should not see the
"Remove abuse"
dropdown / button
features/steps/abuse_reports.rb
View file @
5f95a5e0
...
@@ -22,6 +22,11 @@ class Spinach::Features::AbuseReports < Spinach::FeatureSteps
...
@@ -22,6 +22,11 @@ class Spinach::Features::AbuseReports < Spinach::FeatureSteps
user_mike
user_mike
end
end
step
'I should not see the "Remove abuse" dropdown / button'
do
expect
(
find
(
:css
,
'#report_abuse'
)).
not_to
have_selector
(
:css
,
'ul.dropdown-menu'
)
expect
(
find
(
:css
,
'#report_abuse'
)).
to
have_selector
(
:css
,
'.btn-close'
)
end
def
user_mike
def
user_mike
@user_mike
||=
create
(
:user
,
name:
'Mike'
)
@user_mike
||=
create
(
:user
,
name:
'Mike'
)
end
end
...
...
spec/features/users_spec.rb
View file @
5f95a5e0
require
'spec_helper'
require
'spec_helper'
feature
'Users'
,
feature:
true
do
feature
'Users'
,
feature:
true
do
let
(
:user
)
{
create
(
:user
,
username:
'user1'
,
name:
'User 1'
,
email:
'user1@gitlab.com'
)
}
let
(
:user2
)
{
create
(
:user
,
username:
'user2'
,
name:
'User 2'
,
email:
'user2@gitlab.com'
)
}
scenario
'GET /users/sign_in creates a new user account'
do
scenario
'GET /users/sign_in creates a new user account'
do
visit
new_user_session_path
visit
new_user_session_path
fill_in
'user_name'
,
with:
'Name Surname'
fill_in
'user_name'
,
with:
'Name Surname'
...
@@ -11,7 +14,6 @@ feature 'Users', feature: true do
...
@@ -11,7 +14,6 @@ feature 'Users', feature: true do
end
end
scenario
'Successful user signin invalidates password reset token'
do
scenario
'Successful user signin invalidates password reset token'
do
user
=
create
(
:user
)
expect
(
user
.
reset_password_token
).
to
be_nil
expect
(
user
.
reset_password_token
).
to
be_nil
visit
new_user_password_path
visit
new_user_password_path
...
@@ -28,7 +30,6 @@ feature 'Users', feature: true do
...
@@ -28,7 +30,6 @@ feature 'Users', feature: true do
expect
(
user
.
reset_password_token
).
to
be_nil
expect
(
user
.
reset_password_token
).
to
be_nil
end
end
let!
(
:user
)
{
create
(
:user
,
username:
'user1'
,
name:
'User 1'
,
email:
'user1@gitlab.com'
)
}
scenario
'Should show one error if email is already taken'
do
scenario
'Should show one error if email is already taken'
do
visit
new_user_session_path
visit
new_user_session_path
fill_in
'user_name'
,
with:
'Another user name'
fill_in
'user_name'
,
with:
'Another user name'
...
@@ -48,4 +49,37 @@ feature 'Users', feature: true do
...
@@ -48,4 +49,37 @@ feature 'Users', feature: true do
page
.
find
(
'#error_explanation'
).
find
(
'ul'
).
all
(
'li'
).
count
page
.
find
(
'#error_explanation'
).
find
(
'ul'
).
all
(
'li'
).
count
end
end
context
'With a logged-in user'
do
before
do
login_as
(
user
)
end
describe
'Abuse report button'
do
context
'User has never been reported for abuse'
do
it
'enables the "Report abuse" button / dropdown'
do
visit
user_path
(
user2
)
expect
(
page
.
find
(
'#report_abuse'
).
find
(
'ul.dropdown-menu'
).
all
(
'li'
).
count
).
to
be
(
1
)
expect
(
page
.
find
(
'#report_abuse'
).
all
(
'.btn-close'
).
count
).
to
be
(
0
)
end
end
context
'User has already been reported for abuse'
do
before
do
@abuse_report
=
AbuseReport
.
new
(
user:
user2
,
message:
'Foo bar'
)
@abuse_report
.
reporter
=
user
@abuse_report
.
save!
end
it
'disables the "Report abuse" button'
do
visit
user_path
(
user2
)
expect
(
page
.
find
(
'#report_abuse'
).
all
(
'ul.dropdown-menu'
).
count
).
to
be
(
0
)
expect
(
page
.
find
(
'#report_abuse'
).
all
(
'.btn-close'
).
count
).
to
be
(
1
)
end
end
end
end
end
end
spec/models/user_spec.rb
View file @
5f95a5e0
...
@@ -73,6 +73,7 @@ describe User do
...
@@ -73,6 +73,7 @@ describe User do
describe
'associations'
do
describe
'associations'
do
it
{
is_expected
.
to
have_one
(
:namespace
)
}
it
{
is_expected
.
to
have_one
(
:namespace
)
}
it
{
is_expected
.
to
have_one
(
:abuse_report
)
}
it
{
is_expected
.
to
have_many
(
:snippets
).
class_name
(
'Snippet'
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:snippets
).
class_name
(
'Snippet'
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:project_members
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:project_members
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:groups
)
}
it
{
is_expected
.
to
have_many
(
:groups
)
}
...
...
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