2016-07-27 16:41:19 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe Boards::CreateService do
|
2016-07-27 16:41:19 -04:00
|
|
|
describe '#execute' do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2016-10-06 15:20:21 -04:00
|
|
|
|
2016-08-02 20:49:26 -04:00
|
|
|
subject(:service) { described_class.new(project, double) }
|
2016-07-27 16:41:19 -04:00
|
|
|
|
2016-07-28 00:36:38 -04:00
|
|
|
context 'when project does not have a board' do
|
|
|
|
it 'creates a new board' do
|
|
|
|
expect { service.execute }.to change(Board, :count).by(1)
|
|
|
|
end
|
|
|
|
|
2017-01-27 00:23:55 -05:00
|
|
|
it 'creates the default lists' do
|
2016-10-06 15:20:21 -04:00
|
|
|
board = service.execute
|
2016-07-28 00:36:38 -04:00
|
|
|
|
2017-05-31 10:34:02 -04:00
|
|
|
expect(board.lists.size).to eq 2
|
|
|
|
expect(board.lists.first).to be_backlog
|
|
|
|
expect(board.lists.last).to be_closed
|
2016-07-28 00:36:38 -04:00
|
|
|
end
|
2016-07-27 16:41:19 -04:00
|
|
|
end
|
|
|
|
|
2016-07-28 00:36:38 -04:00
|
|
|
context 'when project has a board' do
|
2016-10-06 15:20:21 -04:00
|
|
|
before do
|
|
|
|
create(:board, project: project)
|
2016-07-28 00:36:38 -04:00
|
|
|
end
|
2016-07-27 16:41:19 -04:00
|
|
|
|
2016-10-06 15:20:21 -04:00
|
|
|
it 'does not create a new board' do
|
2017-07-07 05:50:01 -04:00
|
|
|
expect(service).to receive(:can_create_board?) { false }
|
|
|
|
|
2016-10-06 15:20:21 -04:00
|
|
|
expect { service.execute }.not_to change(project.boards, :count)
|
2016-07-28 00:36:38 -04:00
|
|
|
end
|
2016-07-27 16:41:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|