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
3e2ef953
Commit
3e2ef953
authored
Jan 25, 2020
by
GitLab Bot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add latest changes from gitlab-org/gitlab@master
parent
35487a1e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
118 additions
and
2 deletions
+118
-2
app/graphql/resolvers/boards_resolver.rb
app/graphql/resolvers/boards_resolver.rb
+18
-0
app/graphql/types/board_type.rb
app/graphql/types/board_type.rb
+17
-0
app/services/boards/list_service.rb
app/services/boards/list_service.rb
+2
-2
spec/graphql/resolvers/boards_resolver_spec.rb
spec/graphql/resolvers/boards_resolver_spec.rb
+75
-0
spec/support/shared_examples/services/boards/boards_list_service_shared_examples.rb
...es/services/boards/boards_list_service_shared_examples.rb
+6
-0
No files found.
app/graphql/resolvers/boards_resolver.rb
0 → 100644
View file @
3e2ef953
# frozen_string_literal: true
module
Resolvers
class
BoardsResolver
<
BaseResolver
type
Types
::
BoardType
,
null:
true
def
resolve
(
**
args
)
# The project or group could have been loaded in batch by `BatchLoader`.
# At this point we need the `id` of the project/group to query for boards, so
# make sure it's loaded and not `nil` before continuing.
parent
=
object
.
respond_to?
(
:sync
)
?
object
.
sync
:
object
return
Board
.
none
unless
parent
Boards
::
ListService
.
new
(
parent
,
context
[
:current_user
]).
execute
(
create_default_board:
false
)
end
end
end
app/graphql/types/board_type.rb
0 → 100644
View file @
3e2ef953
# frozen_string_literal: true
module
Types
class
BoardType
<
BaseObject
graphql_name
'Board'
description
'Represents a project or group board'
authorize
:read_board
field
:id
,
type:
GraphQL
::
ID_TYPE
,
null:
false
,
description:
'ID (global ID) of the board'
field
:name
,
type:
GraphQL
::
STRING_TYPE
,
null:
true
,
description:
'Name of the board'
end
end
Types
::
BoardType
.
prepend_if_ee
(
'::EE::Types::BoardType'
)
app/services/boards/list_service.rb
View file @
3e2ef953
...
...
@@ -2,8 +2,8 @@
module
Boards
class
ListService
<
Boards
::
BaseService
def
execute
create_board!
if
parent
.
boards
.
empty?
def
execute
(
create_default_board:
true
)
create_board!
if
create_default_board
&&
parent
.
boards
.
empty?
if
parent
.
multiple_issue_boards_available?
boards
...
...
spec/graphql/resolvers/boards_resolver_spec.rb
0 → 100644
View file @
3e2ef953
# frozen_string_literal: true
require
'spec_helper'
describe
Resolvers
::
BoardsResolver
do
include
GraphqlHelpers
let_it_be
(
:user
)
{
create
(
:user
)
}
shared_examples_for
'group and project boards resolver'
do
it
'does not create a default board'
do
expect
(
resolve_boards
).
to
eq
[]
end
it
'calls Boards::ListService'
do
expect_next_instance_of
(
Boards
::
ListService
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
)
end
resolve_boards
end
it
'avoids N+1 queries'
do
control
=
ActiveRecord
::
QueryRecorder
.
new
{
resolve_boards
(
args:
{})
}
create
(
:milestone
,
"
#{
board_parent
.
class
.
name
.
underscore
}
"
:
board_parent
)
create
(
:board
,
resource_parent:
board_parent
)
expect
{
resolve_boards
(
args:
{})
}.
not_to
exceed_query_limit
(
control
)
end
describe
'multiple_issue_boards_available?'
do
let!
(
:board2
)
{
create
(
:board
,
name:
'Two'
,
resource_parent:
board_parent
)
}
let!
(
:board1
)
{
create
(
:board
,
name:
'One'
,
resource_parent:
board_parent
)
}
it
'returns multiple boards'
do
allow
(
board_parent
).
to
receive
(
:multiple_issue_boards_available?
).
and_return
(
true
)
expect
(
resolve_boards
).
to
eq
[
board1
,
board2
]
end
it
'returns only the first boards'
do
allow
(
board_parent
).
to
receive
(
:multiple_issue_boards_available?
).
and_return
(
false
)
expect
(
resolve_boards
).
to
eq
[
board1
]
end
end
end
describe
'#resolve'
do
context
'when there is no parent'
do
let
(
:board_parent
)
{
nil
}
it
'returns none if parent is nil'
do
expect
(
resolve_boards
).
to
eq
(
Board
.
none
)
end
end
context
'when project boards'
do
let
(
:board_parent
)
{
create
(
:project
,
:public
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
it_behaves_like
'group and project boards resolver'
end
context
'when group boards'
do
let
(
:board_parent
)
{
create
(
:group
)
}
it_behaves_like
'group and project boards resolver'
end
end
def
resolve_boards
(
args:
{})
resolve
(
described_class
,
obj:
board_parent
,
args:
args
,
ctx:
{
current_user:
user
})
end
end
spec/support/shared_examples/services/boards/boards_list_service_shared_examples.rb
View file @
3e2ef953
...
...
@@ -11,6 +11,12 @@ RSpec.shared_examples 'boards list service' do
service
.
execute
end
context
'when create_default_board is false'
do
it
'does not create a new parent board'
do
expect
{
service
.
execute
(
create_default_board:
false
)
}.
not_to
change
(
parent
.
boards
,
:count
)
end
end
end
context
'when parent has a board'
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