This makes the Boards::CreateService
more reusable for EE
This commit is contained in:
parent
de2d5ce685
commit
c478202ebf
2 changed files with 13 additions and 8 deletions
|
@ -1,19 +1,22 @@
|
|||
module Boards
|
||||
class CreateService < BaseService
|
||||
def execute
|
||||
if project.boards.empty?
|
||||
create_board!
|
||||
else
|
||||
project.boards.first
|
||||
end
|
||||
create_board! if can_create_board?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def can_create_board?
|
||||
project.boards.size == 0
|
||||
end
|
||||
|
||||
def create_board!
|
||||
board = project.boards.create
|
||||
board = project.boards.create(params)
|
||||
|
||||
if board.persisted?
|
||||
board.lists.create(list_type: :backlog)
|
||||
board.lists.create(list_type: :closed)
|
||||
end
|
||||
|
||||
board
|
||||
end
|
||||
|
|
|
@ -26,6 +26,8 @@ describe Boards::CreateService, services: true do
|
|||
end
|
||||
|
||||
it 'does not create a new board' do
|
||||
expect(service).to receive(:can_create_board?) { false }
|
||||
|
||||
expect { service.execute }.not_to change(project.boards, :count)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue