summaryrefslogtreecommitdiff
path: root/spec/services/boards/issues/create_service_spec.rb
blob: 1a56164dba4917c9169d670b433484f74589949e (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
33
require 'spec_helper'

describe Boards::Issues::CreateService do
  describe '#execute' do
    let(:project) { create(:project) }
    let(:board)   { create(:board, project: project) }
    let(:user)    { create(:user) }
    let(:label)   { create(:label, project: project, name: 'in-progress') }
    let!(:list)   { create(:list, board: board, label: label, position: 0) }

    subject(:service) { described_class.new(board.parent, project, user, board_id: board.id, list_id: list.id, title: 'New issue') }

    before do
      project.team << [user, :developer]
    end

    it 'delegates the create proceedings to Issues::CreateService' do
      expect_any_instance_of(Issues::CreateService).to receive(:execute).once

      service.execute
    end

    it 'creates a new issue' do
      expect { service.execute }.to change(project.issues, :count).by(1)
    end

    it 'adds the label of the list to the issue' do
      issue = service.execute

      expect(issue.labels).to eq [label]
    end
  end
end