Commit dc1d5ee8 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Reuse `Boards::CreateService` for EE

We only overwrite `can_create_board?` so it allows creating multiple
boards when available.
parent fd085bf6
......@@ -9,7 +9,7 @@ module EE
end
def create
board = EE::Boards::CreateService.new(project, current_user, board_params).execute
board = ::Boards::CreateService.new(project, current_user, board_params).execute
respond_to do |format|
format.json do
......
module EE
module Boards
class CreateService < BaseService
def execute
return nil unless can_create_board?
board = project.boards.create(params)
if board.persisted?
board.lists.create(list_type: :backlog)
board.lists.create(list_type: :closed)
end
board
end
module CreateService
def can_create_board?
project.feature_available?(:multiple_issue_boards) || project.boards.size < 1
raise NotImplementedError unless defined?(super)
project.feature_available?(:multiple_issue_boards) || super
end
end
end
......
require 'spec_helper'
describe EE::Boards::CreateService, services: true do
describe Boards::CreateService, services: true do
describe '#execute' do
let(:project) { create(:empty_project) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment