Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-10-06 22:20:21 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-10-11 17:39:04 +0300
commite46a4aabd925e0182c31976b5d28c38b9a8a0872 (patch)
tree8400151d252bb7d2bb7010be56c5bef196d5b311 /app/services/boards
parent95a5cc9285a8583988ece697ebdb948730b5db55 (diff)
Update Boards::CreateService to handle with the has_many association
Diffstat (limited to 'app/services/boards')
-rw-r--r--app/services/boards/create_service.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/app/services/boards/create_service.rb b/app/services/boards/create_service.rb
index 072a0749285..a9dbd76a44a 100644
--- a/app/services/boards/create_service.rb
+++ b/app/services/boards/create_service.rb
@@ -1,16 +1,21 @@
module Boards
class CreateService < Boards::BaseService
def execute
- create_board! unless project.board.present?
- project.board
+ if project.boards.empty?
+ create_board!
+ else
+ project.boards.first
+ end
end
private
def create_board!
- project.create_board
- project.board.lists.create(list_type: :backlog)
- project.board.lists.create(list_type: :done)
+ board = project.boards.create
+ board.lists.create(list_type: :backlog)
+ board.lists.create(list_type: :done)
+
+ board
end
end
end