2016-08-08 19:34:38 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 14:24:02 +00:00
|
|
|
describe Boards::Lists::GenerateService do
|
2016-08-08 19:34:38 +00:00
|
|
|
describe '#execute' do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project) }
|
2016-10-05 17:06:34 +00:00
|
|
|
let(:board) { create(:board, project: project) }
|
2016-08-08 19:34:38 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
subject(:service) { described_class.new(project, user) }
|
|
|
|
|
2016-09-19 20:34:27 +00:00
|
|
|
before do
|
2017-12-22 08:18:28 +00:00
|
|
|
project.add_developer(user)
|
2016-09-19 20:34:27 +00:00
|
|
|
end
|
|
|
|
|
2016-08-08 19:34:38 +00:00
|
|
|
context 'when board lists is empty' do
|
|
|
|
it 'creates the default lists' do
|
2016-10-05 17:06:34 +00:00
|
|
|
expect { service.execute(board) }.to change(board.lists, :count).by(2)
|
2016-08-08 19:34:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when board lists is not empty' do
|
|
|
|
it 'does not creates the default lists' do
|
|
|
|
create(:list, board: board)
|
|
|
|
|
2016-10-05 17:06:34 +00:00
|
|
|
expect { service.execute(board) }.not_to change(board.lists, :count)
|
2016-08-08 19:34:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when project labels does not contains any list label' do
|
|
|
|
it 'creates labels' do
|
2016-10-05 17:06:34 +00:00
|
|
|
expect { service.execute(board) }.to change(project.labels, :count).by(2)
|
2016-08-08 19:34:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when project labels contains some of list label' do
|
|
|
|
it 'creates the missing labels' do
|
2016-10-06 14:46:07 +00:00
|
|
|
create(:label, project: project, name: 'Doing')
|
2016-08-08 19:34:38 +00:00
|
|
|
|
2016-10-05 17:06:34 +00:00
|
|
|
expect { service.execute(board) }.to change(project.labels, :count).by(1)
|
2016-08-08 19:34:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|