2016-10-05 19:01:06 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 14:24:02 +00:00
|
|
|
describe Boards::ListService do
|
2016-10-05 19:01:06 +00:00
|
|
|
describe '#execute' do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project) }
|
2016-10-05 19:01:06 +00:00
|
|
|
|
|
|
|
subject(:service) { described_class.new(project, double) }
|
|
|
|
|
|
|
|
context 'when project does not have a board' do
|
|
|
|
it 'creates a new project board' do
|
|
|
|
expect { service.execute }.to change(project.boards, :count).by(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'delegates the project board creation to Boards::CreateService' do
|
|
|
|
expect_any_instance_of(Boards::CreateService).to receive(:execute).once
|
|
|
|
|
|
|
|
service.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when project has a board' do
|
|
|
|
before do
|
|
|
|
create(:board, project: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not create a new board' do
|
|
|
|
expect { service.execute }.not_to change(project.boards, :count)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns project boards' do
|
|
|
|
board = create(:board, project: project)
|
|
|
|
|
|
|
|
expect(service.execute).to match_array [board]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|