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
c85591e6
Commit
c85591e6
authored
Feb 01, 2021
by
Jarka Košanová
Committed by
Mayra Cabrera
Feb 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display epic related events on user activity feed
- change the query - add specs for issues & epics erlated queries
parent
f192d901
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
21 deletions
+53
-21
app/finders/user_recent_events_finder.rb
app/finders/user_recent_events_finder.rb
+2
-21
changelogs/unreleased/196835-fix-epic-feed.yml
changelogs/unreleased/196835-fix-epic-feed.yml
+5
-0
ee/spec/finders/ee/user_recent_events_finder_spec.rb
ee/spec/finders/ee/user_recent_events_finder_spec.rb
+32
-0
spec/finders/user_recent_events_finder_spec.rb
spec/finders/user_recent_events_finder_spec.rb
+14
-0
No files found.
app/finders/user_recent_events_finder.rb
View file @
c85591e6
...
...
@@ -26,42 +26,23 @@ class UserRecentEventsFinder
@params
=
params
end
# rubocop: disable CodeReuse/ActiveRecord
def
execute
return
Event
.
none
unless
can?
(
current_user
,
:read_user_profile
,
target_user
)
recent_events
(
params
[
:offset
]
||
0
)
.
joins
(
:project
)
target_events
.
with_associations
.
limit_recent
(
limit
,
params
[
:offset
])
.
order_created_desc
end
# rubocop: enable CodeReuse/ActiveRecord
private
# rubocop: disable CodeReuse/ActiveRecord
def
recent_events
(
offset
)
sql
=
<<~
SQL
(
#{
projects
}
) AS projects_for_join
JOIN (
#{
target_events
.
to_sql
}
) AS
#{
Event
.
table_name
}
ON
#{
Event
.
table_name
}
.project_id = projects_for_join.id
SQL
# Workaround for https://github.com/rails/rails/issues/24193
Event
.
from
([
Arel
.
sql
(
sql
)])
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
target_events
Event
.
where
(
author:
target_user
)
end
# rubocop: enable CodeReuse/ActiveRecord
def
projects
target_user
.
project_interactions
.
to_sql
end
def
limit
return
DEFAULT_LIMIT
unless
params
[
:limit
].
present?
...
...
changelogs/unreleased/196835-fix-epic-feed.yml
0 → 100644
View file @
c85591e6
---
title
:
Display epic related events on user activity feed
merge_request
:
52611
author
:
type
:
added
ee/spec/finders/ee/user_recent_events_finder_spec.rb
0 → 100644
View file @
c85591e6
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
UserRecentEventsFinder
do
describe
'#execute'
do
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:epic
)
{
create
(
:epic
)
}
let_it_be
(
:private_epic
)
{
create
(
:epic
,
group:
create
(
:group
,
:private
))
}
let_it_be
(
:note
)
{
create
(
:note_on_epic
,
noteable:
epic
)
}
let_it_be
(
:public_event
)
{
create
(
:event
,
:commented
,
target:
note
,
author:
user
,
project:
nil
)
}
let_it_be
(
:private_event
)
{
create
(
:event
,
:closed
,
target:
private_epic
,
author:
user
,
project:
nil
)
}
subject
{
described_class
.
new
(
current_user
,
user
,
{}).
execute
}
context
'epic related activities'
do
context
'when profile is public'
do
it
{
is_expected
.
to
match_array
([
public_event
,
private_event
])
}
end
context
'when profile is private'
do
before
do
allow
(
Ability
).
to
receive
(
:allowed?
).
and_call_original
allow
(
Ability
).
to
receive
(
:allowed?
).
with
(
current_user
,
:read_user_profile
,
user
).
and_return
(
false
)
end
it
{
is_expected
.
to
be_empty
}
end
end
end
end
spec/finders/user_recent_events_finder_spec.rb
View file @
c85591e6
...
...
@@ -51,6 +51,20 @@ RSpec.describe UserRecentEventsFinder do
end
end
describe
'issue activity events'
do
let
(
:issue
)
{
create
(
:issue
,
project:
public_project
)
}
let
(
:note
)
{
create
(
:note_on_issue
,
noteable:
issue
,
project:
public_project
)
}
let!
(
:event_a
)
{
create
(
:event
,
:commented
,
target:
note
,
author:
project_owner
)
}
let!
(
:event_b
)
{
create
(
:event
,
:closed
,
target:
issue
,
author:
project_owner
)
}
it
'includes all issue related events'
,
:aggregate_failures
do
events
=
finder
.
execute
expect
(
events
).
to
include
(
event_a
)
expect
(
events
).
to
include
(
event_b
)
end
end
context
'limits'
do
before
do
stub_const
(
"
#{
described_class
}
::DEFAULT_LIMIT"
,
1
)
...
...
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