debian-mirror-gitlab/spec/services/boards/create_service_spec.rb

36 lines
895 B
Ruby
Raw Normal View History

2016-09-13 17:45:13 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe Boards::CreateService do
2016-09-13 17:45:13 +05:30
describe '#execute' do
2017-09-10 17:25:29 +05:30
let(:project) { create(:project) }
2016-11-03 12:29:30 +05:30
2016-09-13 17:45:13 +05:30
subject(:service) { described_class.new(project, double) }
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-08-17 22:00:37 +05:30
it 'creates the default lists' do
2016-11-03 12:29:30 +05:30
board = service.execute
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
expect(board.lists.size).to eq 2
expect(board.lists.first).to be_backlog
expect(board.lists.last).to be_closed
2016-09-13 17:45:13 +05:30
end
end
context 'when project has a board' do
2016-11-03 12:29:30 +05:30
before do
create(:board, project: project)
2016-09-13 17:45:13 +05:30
end
2016-11-03 12:29:30 +05:30
it 'does not create a new board' do
2017-09-10 17:25:29 +05:30
expect(service).to receive(:can_create_board?) { false }
2016-11-03 12:29:30 +05:30
expect { service.execute }.not_to change(project.boards, :count)
2016-09-13 17:45:13 +05:30
end
end
end
end