summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/services/boards/boards_list_service.rb
blob: 566e5050f8e03f2ea54dfb763326a3b00a600446 (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
# frozen_string_literal: true

shared_examples 'boards list service' do
  context 'when parent does not have a board' do
    it 'creates a new parent board' do
      expect { service.execute }.to change(parent.boards, :count).by(1)
    end

    it 'delegates the parent board creation to Boards::CreateService' do
      expect_any_instance_of(Boards::CreateService).to receive(:execute).once

      service.execute
    end
  end

  context 'when parent has a board' do
    before do
      create(:board, parent: parent)
    end

    it 'does not create a new board' do
      expect { service.execute }.not_to change(parent.boards, :count)
    end
  end

  it 'returns parent boards' do
    board = create(:board, parent: parent)

    expect(service.execute).to eq [board]
  end
end