debian-mirror-gitlab/spec/services/boards/issues/create_service_spec.rb

38 lines
1.1 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2016-11-03 12:29:30 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe Boards::Issues::CreateService do
2016-11-03 12:29:30 +05:30
describe '#execute' do
2017-09-10 17:25:29 +05:30
let(:project) { create(:project) }
2016-11-03 12:29:30 +05:30
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) }
2019-12-21 20:55:43 +05:30
subject(:service) { described_class.new(board.resource_parent, project, user, board_id: board.id, list_id: list.id, title: 'New issue') }
2016-11-03 12:29:30 +05:30
before do
2018-03-17 18:26:18 +05:30
project.add_developer(user)
2016-11-03 12:29:30 +05:30
end
it 'delegates the create proceedings to Issues::CreateService' do
2020-01-01 13:55:28 +05:30
expect_next_instance_of(Issues::CreateService) do |instance|
expect(instance).to receive(:execute).once
end
2016-11-03 12:29:30 +05:30
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