diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-04 23:41:00 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-10-06 13:00:01 +0300 |
commit | 97ec0c05f66e40a6de6620efcf5c92b7c2979f95 (patch) | |
tree | 526b5f675205be58ed0a0ac32a09af6cc250913b /spec/services/boards | |
parent | e7a4bbb04a86259a569f6ac239ecb35ad36f39b5 (diff) |
Add service to create a new issue in a board list
Diffstat (limited to 'spec/services/boards')
-rw-r--r-- | spec/services/boards/issues/create_service_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/services/boards/issues/create_service_spec.rb b/spec/services/boards/issues/create_service_spec.rb new file mode 100644 index 00000000000..33e10e79f6d --- /dev/null +++ b/spec/services/boards/issues/create_service_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe Boards::Issues::CreateService, services: true do + describe '#execute' do + let(:project) { create(:project_with_board) } + let(:board) { project.board } + 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(project, user, 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(list) + end + + it 'creates a new issue' do + expect { service.execute(list) }.to change(project.issues, :count).by(1) + end + + it 'adds the label of the list to the issue' do + issue = service.execute(list) + + expect(issue.labels).to eq [label] + end + end +end |