2019-04-11 12:17:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-04 20:41:00 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 14:24:02 +00:00
|
|
|
describe Boards::Issues::CreateService do
|
2016-10-04 20:41:00 +00:00
|
|
|
describe '#execute' do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project) }
|
2016-10-06 20:13:33 +00:00
|
|
|
let(:board) { create(:board, project: project) }
|
2016-10-04 20:41:00 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:label) { create(:label, project: project, name: 'in-progress') }
|
|
|
|
let!(:list) { create(:list, board: board, label: label, position: 0) }
|
|
|
|
|
2019-10-17 12:07:33 +00:00
|
|
|
subject(:service) { described_class.new(board.resource_parent, project, user, board_id: board.id, list_id: list.id, title: 'New issue') }
|
2016-10-04 20:41:00 +00:00
|
|
|
|
|
|
|
before do
|
2017-12-22 08:18:28 +00:00
|
|
|
project.add_developer(user)
|
2016-10-04 20:41:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'delegates the create proceedings to Issues::CreateService' do
|
2019-12-16 12:07:43 +00:00
|
|
|
expect_next_instance_of(Issues::CreateService) do |instance|
|
|
|
|
expect(instance).to receive(:execute).once
|
|
|
|
end
|
2016-10-04 20:41:00 +00:00
|
|
|
|
2016-10-06 20:13:33 +00:00
|
|
|
service.execute
|
2016-10-04 20:41:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates a new issue' do
|
2016-10-06 20:13:33 +00:00
|
|
|
expect { service.execute }.to change(project.issues, :count).by(1)
|
2016-10-04 20:41:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'adds the label of the list to the issue' do
|
2016-10-06 20:13:33 +00:00
|
|
|
issue = service.execute
|
2016-10-04 20:41:00 +00:00
|
|
|
|
|
|
|
expect(issue.labels).to eq [label]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|