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
7dbf027c
Commit
7dbf027c
authored
Jun 13, 2018
by
Mario de la Ossa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Boards - extract `Boards::UsersFinder`
parent
89497f61
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
18 deletions
+64
-18
ee/app/controllers/boards/users_controller.rb
ee/app/controllers/boards/users_controller.rb
+3
-11
ee/app/finders/boards/users_finder.rb
ee/app/finders/boards/users_finder.rb
+23
-0
ee/app/services/ee/boards/lists/create_service.rb
ee/app/services/ee/boards/lists/create_service.rb
+2
-7
ee/spec/finders/boards/users_finder_spec.rb
ee/spec/finders/boards/users_finder_spec.rb
+36
-0
No files found.
ee/app/controllers/boards/users_controller.rb
View file @
7dbf027c
...
...
@@ -5,10 +5,7 @@ module Boards
# If board parent is a group it enumerates all members of current group,
# ancestors, and descendants
def
index
user_ids
=
finder_service
.
execute
(
include_descendants:
true
)
.
non_invite
.
select
(
:user_id
)
user_ids
=
user_finder
.
execute
.
select
(
:user_id
)
users
=
User
.
where
(
id:
user_ids
)
...
...
@@ -17,13 +14,8 @@ module Boards
private
def
finder_service
@service
||=
if
board_parent
.
is_a?
(
Group
)
GroupMembersFinder
.
new
(
board_parent
)
else
MembersFinder
.
new
(
board_parent
,
current_user
)
end
def
user_finder
@user_finder
||=
Boards
::
UsersFinder
.
new
(
board
,
current_user
)
end
end
end
ee/app/finders/boards/users_finder.rb
0 → 100644
View file @
7dbf027c
module
Boards
class
UsersFinder
def
initialize
(
board
,
current_user
=
nil
)
@board
=
board
@current_user
=
current_user
end
def
execute
finder_service
.
execute
(
include_descendants:
true
).
non_invite
end
private
def
finder_service
@finder_service
||=
if
@board
.
parent
.
is_a?
(
Group
)
GroupMembersFinder
.
new
(
@board
.
parent
)
else
MembersFinder
.
new
(
@board
.
parent
,
@current_user
)
end
end
end
end
ee/app/services/ee/boards/lists/create_service.rb
View file @
7dbf027c
...
...
@@ -24,17 +24,12 @@ module EE
end
def
find_user
(
board
)
user_ids
=
user_finder
(
board
).
execute
(
include_descendants:
true
).
non_invite
.
select
(
:user_id
)
user_ids
=
user_finder
(
board
).
select
(
:user_id
)
::
User
.
where
(
id:
user_ids
).
find
(
params
[
:assignee_id
])
end
def
user_finder
(
board
)
@service
||=
if
board
.
parent
.
is_a?
(
Group
)
GroupMembersFinder
.
new
(
board
.
parent
)
else
MembersFinder
.
new
(
board
.
parent
,
current_user
)
end
@user_finder
||=
Boards
::
UsersFinder
.
new
(
board
,
current_user
)
end
end
end
...
...
ee/spec/finders/boards/users_finder_spec.rb
0 → 100644
View file @
7dbf027c
require
'spec_helper'
describe
Boards
::
UsersFinder
do
describe
'#execute'
do
subject
{
described_class
.
new
(
board
)
}
context
'when parent is a project'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:board
)
{
create
(
:board
,
project:
project
)
}
it
'finds ProjectMembers with MemberFinder'
do
results
=
subject
.
execute
expect
(
subject
.
instance_variable_get
(
:@finder_service
)).
to
be_kind_of
(
MembersFinder
)
expect
(
results
.
first
).
to
be_kind_of
(
ProjectMember
)
end
end
context
'when parent is a group'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:board
)
{
create
(
:board
,
group:
group
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
group
.
add_developer
(
user
)
end
it
'finds GroupMembers with GroupMemberFinder'
do
results
=
subject
.
execute
expect
(
subject
.
instance_variable_get
(
:@finder_service
)).
to
be_kind_of
(
GroupMembersFinder
)
expect
(
results
.
first
).
to
be_kind_of
(
GroupMember
)
end
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