summaryrefslogtreecommitdiff
path: root/spec/services/boards/create_service_spec.rb
blob: a8555f5b4a0558265d6e8e50fa29aae571b9cdc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'spec_helper'

describe Boards::CreateService, services: true do
  describe '#execute' do
    let(:project) { create(:empty_project) }

    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

      it 'creates the default lists' do
        board = service.execute

        expect(board.lists.size).to eq 1
        expect(board.lists.first).to be_closed
      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
  end
end