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
e726ed5e
Commit
e726ed5e
authored
Aug 03, 2019
by
Camil Staps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle reviewer comments on !24690
parent
d2b2486a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
18 deletions
+28
-18
app/finders/starred_projects_finder.rb
app/finders/starred_projects_finder.rb
+5
-3
app/finders/users_star_projects_finder.rb
app/finders/users_star_projects_finder.rb
+1
-1
app/models/user.rb
app/models/user.rb
+8
-6
app/models/users_star_project.rb
app/models/users_star_project.rb
+2
-2
spec/controllers/projects/starrers_controller_spec.rb
spec/controllers/projects/starrers_controller_spec.rb
+2
-0
spec/finders/starred_projects_finder_spec.rb
spec/finders/starred_projects_finder_spec.rb
+5
-3
spec/finders/users_star_projects_finder_spec.rb
spec/finders/users_star_projects_finder_spec.rb
+5
-3
No files found.
app/finders/starred_projects_finder.rb
View file @
e726ed5e
...
...
@@ -2,8 +2,10 @@
class
StarredProjectsFinder
<
ProjectsFinder
def
initialize
(
user
,
params:
{},
current_user:
nil
)
project_ids
=
user
.
starred_projects
.
select
(
:id
)
super
(
params:
params
,
current_user:
current_user
,
project_ids_relation:
project_ids
)
super
(
params:
params
,
current_user:
current_user
,
project_ids_relation:
user
.
starred_projects
.
select
(
:id
)
)
end
end
app/finders/users_star_projects_finder.rb
View file @
e726ed5e
...
...
@@ -12,7 +12,7 @@ class UsersStarProjectsFinder
end
def
execute
stars
=
UsersStarProject
.
all
.
order_id_desc
stars
=
UsersStarProject
.
all
stars
=
by_project
(
stars
)
stars
=
by_search
(
stars
)
stars
=
filter_visible_profiles
(
stars
)
...
...
app/models/user.rb
View file @
e726ed5e
...
...
@@ -282,15 +282,17 @@ class User < ApplicationRecord
scope
:for_todos
,
->
(
todos
)
{
where
(
id:
todos
.
select
(
:user_id
))
}
scope
:with_emails
,
->
{
preload
(
:emails
)
}
scope
:with_dashboard
,
->
(
dashboard
)
{
where
(
dashboard:
dashboard
)
}
scope
:with_visible_profile
,
->
(
user
)
{
if
user
.
nil?
where
(
private_profile:
false
)
elsif
user
.
admin?
scope
:with_public_profile
,
->
{
where
(
private_profile:
false
)
}
def
self
.
with_visible_profile
(
user
)
return
with_public_profile
if
user
.
nil?
if
user
.
admin?
all
else
w
here
(
private_profile:
false
).
or
where
(
id:
user
.
id
)
w
ith_public_profile
.
or
(
where
(
id:
user
.
id
)
)
end
}
end
# Limits the users to those that have TODOs, optionally in the given state.
#
...
...
app/models/users_star_project.rb
View file @
e726ed5e
...
...
@@ -12,8 +12,8 @@ class UsersStarProject < ApplicationRecord
alias_attribute
:starred_since
,
:created_at
scope
:order_user_name_asc
,
->
{
joins
(
:user
).
reorder
(
'users.name ASC'
)
}
scope
:order_user_name_desc
,
->
{
joins
(
:user
).
reorder
(
'users.name DESC'
)
}
scope
:order_user_name_asc
,
->
{
joins
(
:user
).
merge
(
User
.
order_name_asc
)
}
scope
:order_user_name_desc
,
->
{
joins
(
:user
).
merge
(
User
.
order_name_desc
)
}
scope
:by_project
,
->
(
project
)
{
where
(
project_id:
project
.
id
)
}
scope
:with_visible_profile
,
->
(
user
)
{
joins
(
:user
).
merge
(
User
.
with_visible_profile
(
user
))
}
...
...
spec/controllers/projects/starrers_controller_spec.rb
View file @
e726ed5e
# frozen_string_literal: true
require
'spec_helper'
describe
Projects
::
StarrersController
do
...
...
spec/finders/starred_projects_finder_spec.rb
View file @
e726ed5e
# frozen_string_literal: true
require
'spec_helper'
describe
StarredProjectsFinder
do
...
...
@@ -21,19 +23,19 @@ describe StarredProjectsFinder do
describe
'as same user'
do
let
(
:current_user
)
{
user
}
it
{
is_expected
.
to
eq
([
project2
,
project1
]
)
}
it
{
is_expected
.
to
contain_exactly
(
project1
,
project2
)
}
end
describe
'as other user'
do
let
(
:current_user
)
{
other_user
}
it
{
is_expected
.
to
eq
([
project2
,
project1
]
)
}
it
{
is_expected
.
to
contain_exactly
(
project1
,
project2
)
}
end
describe
'as no user'
do
let
(
:current_user
)
{
nil
}
it
{
is_expected
.
to
eq
([
project2
,
project1
]
)
}
it
{
is_expected
.
to
contain_exactly
(
project1
,
project2
)
}
end
end
end
spec/finders/users_star_projects_finder_spec.rb
View file @
e726ed5e
# frozen_string_literal: true
require
'spec_helper'
describe
UsersStarProjectsFinder
do
...
...
@@ -22,19 +24,19 @@ describe UsersStarProjectsFinder do
describe
'as same user'
do
let
(
:current_user
)
{
private_user
}
it
{
is_expected
.
to
eq
(
private_stars
+
public_stars
)
}
it
{
is_expected
.
to
match_array
(
private_stars
+
public_stars
)
}
end
describe
'as other user'
do
let
(
:current_user
)
{
other_user
}
it
{
is_expected
.
to
eq
(
public_stars
)
}
it
{
is_expected
.
to
match_array
(
public_stars
)
}
end
describe
'as no user'
do
let
(
:current_user
)
{
nil
}
it
{
is_expected
.
to
eq
(
public_stars
)
}
it
{
is_expected
.
to
match_array
(
public_stars
)
}
end
end
end
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