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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
e46a4aab
Commit
e46a4aab
authored
Oct 06, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Boards::CreateService to handle with the has_many association
parent
95a5cc92
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
25 deletions
+25
-25
app/services/boards/create_service.rb
app/services/boards/create_service.rb
+10
-5
spec/factories/boards.rb
spec/factories/boards.rb
+5
-0
spec/factories/projects.rb
spec/factories/projects.rb
+0
-8
spec/services/boards/create_service_spec.rb
spec/services/boards/create_service_spec.rb
+10
-12
No files found.
app/services/boards/create_service.rb
View file @
e46a4aab
module
Boards
module
Boards
class
CreateService
<
Boards
::
BaseService
class
CreateService
<
Boards
::
BaseService
def
execute
def
execute
create_board!
unless
project
.
board
.
present?
if
project
.
boards
.
empty?
project
.
board
create_board!
else
project
.
boards
.
first
end
end
end
private
private
def
create_board!
def
create_board!
project
.
create_board
board
=
project
.
boards
.
create
project
.
board
.
lists
.
create
(
list_type: :backlog
)
board
.
lists
.
create
(
list_type: :backlog
)
project
.
board
.
lists
.
create
(
list_type: :done
)
board
.
lists
.
create
(
list_type: :done
)
board
end
end
end
end
end
end
spec/factories/boards.rb
View file @
e46a4aab
FactoryGirl
.
define
do
FactoryGirl
.
define
do
factory
:board
do
factory
:board
do
project
factory: :empty_project
project
factory: :empty_project
after
(
:create
)
do
|
board
|
board
.
lists
.
create
(
list_type: :backlog
)
board
.
lists
.
create
(
list_type: :done
)
end
end
end
end
end
spec/factories/projects.rb
View file @
e46a4aab
...
@@ -124,12 +124,4 @@ FactoryGirl.define do
...
@@ -124,12 +124,4 @@ FactoryGirl.define do
)
)
end
end
end
end
factory
:project_with_board
,
parent: :empty_project
do
after
(
:create
)
do
|
project
|
project
.
create_board
project
.
board
.
lists
.
create
(
list_type: :backlog
)
project
.
board
.
lists
.
create
(
list_type: :done
)
end
end
end
end
spec/services/boards/create_service_spec.rb
View file @
e46a4aab
...
@@ -2,33 +2,31 @@ require 'spec_helper'
...
@@ -2,33 +2,31 @@ require 'spec_helper'
describe
Boards
::
CreateService
,
services:
true
do
describe
Boards
::
CreateService
,
services:
true
do
describe
'#execute'
do
describe
'#execute'
do
let
(
:project
)
{
create
(
:empty_project
)
}
subject
(
:service
)
{
described_class
.
new
(
project
,
double
)
}
subject
(
:service
)
{
described_class
.
new
(
project
,
double
)
}
context
'when project does not have a board'
do
context
'when project does not have a board'
do
let
(
:project
)
{
create
(
:empty_project
,
board:
nil
)
}
it
'creates a new board'
do
it
'creates a new board'
do
expect
{
service
.
execute
}.
to
change
(
Board
,
:count
).
by
(
1
)
expect
{
service
.
execute
}.
to
change
(
Board
,
:count
).
by
(
1
)
end
end
it
'creates default lists'
do
it
'creates default lists'
do
service
.
execute
board
=
service
.
execute
expect
(
project
.
board
.
lists
.
size
).
to
eq
2
expect
(
board
.
lists
.
size
).
to
eq
2
expect
(
project
.
board
.
lists
.
first
).
to
be_backlog
expect
(
board
.
lists
.
first
).
to
be_backlog
expect
(
project
.
board
.
lists
.
last
).
to
be_done
expect
(
board
.
lists
.
last
).
to
be_done
end
end
end
end
context
'when project has a board'
do
context
'when project has a board'
do
let!
(
:project
)
{
create
(
:project_with_board
)
}
before
do
create
(
:board
,
project:
project
)
it
'does not create a new board'
do
expect
{
service
.
execute
}.
not_to
change
(
Board
,
:count
)
end
end
it
'does not create
board lists
'
do
it
'does not create
a new board
'
do
expect
{
service
.
execute
}.
not_to
change
(
project
.
board
.
list
s
,
:count
)
expect
{
service
.
execute
}.
not_to
change
(
project
.
boards
,
:count
)
end
end
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