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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
691c988c
Commit
691c988c
authored
May 22, 2020
by
Michelle Gill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not show activity for users with private profiles
parent
3a6952c2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
0 deletions
+31
-0
app/finders/events_finder.rb
app/finders/events_finder.rb
+6
-0
changelogs/unreleased/private-profile-api.yml
changelogs/unreleased/private-profile-api.yml
+5
-0
spec/finders/events_finder_spec.rb
spec/finders/events_finder_spec.rb
+7
-0
spec/requests/api/events_spec.rb
spec/requests/api/events_spec.rb
+13
-0
No files found.
app/finders/events_finder.rb
View file @
691c988c
...
...
@@ -33,6 +33,8 @@ class EventsFinder
end
def
execute
return
Event
.
none
if
cannot_access_private_profile?
events
=
get_events
events
=
by_current_user_access
(
events
)
...
...
@@ -103,6 +105,10 @@ class EventsFinder
end
# rubocop: enable CodeReuse/ActiveRecord
def
cannot_access_private_profile?
source
.
is_a?
(
User
)
&&
!
Ability
.
allowed?
(
current_user
,
:read_user_profile
,
source
)
end
def
sort
(
events
)
return
events
unless
params
[
:sort
]
...
...
changelogs/unreleased/private-profile-api.yml
0 → 100644
View file @
691c988c
---
title
:
Do not show activity for users with private profiles
merge_request
:
author
:
type
:
security
spec/finders/events_finder_spec.rb
View file @
691c988c
...
...
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec
.
describe
EventsFinder
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:private_user
)
{
create
(
:user
,
private_profile:
true
)
}
let
(
:other_user
)
{
create
(
:user
)
}
let
(
:project1
)
{
create
(
:project
,
:private
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
...
...
@@ -57,6 +58,12 @@ RSpec.describe EventsFinder do
expect
(
events
).
to
be_empty
end
it
'returns nothing when the target profile is private'
do
events
=
described_class
.
new
(
source:
private_user
,
current_user:
other_user
).
execute
expect
(
events
).
to
be_empty
end
end
describe
'wiki events feature flag'
do
...
...
spec/requests/api/events_spec.rb
View file @
691c988c
...
...
@@ -192,6 +192,19 @@ RSpec.describe API::Events do
end
end
context
'when target users profile is private'
do
it
'returns no events'
do
user
.
update!
(
private_profile:
true
)
private_project
.
add_developer
(
non_member
)
get
api
(
"/users/
#{
user
.
username
}
/events"
,
non_member
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
eq
([])
end
end
context
'when scope is passed'
do
context
'when unauthenticated'
do
it
'returns no user events'
do
...
...
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