Commit b53d9f8a authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add scaffold of service that moves issue to another project

parent c280edd3
module Issues
class MoveService < Issues::BaseService
def execute(issue_old, project_new)
@issue_old = issue_old
@issue_new = issue_old.dup
@project_new = project_new
open_new_issue
rewrite_notes
close_old_issue
notify_participants
@issue_new
end
private
def open_new_issue
@issue_new.project = @project_new
@issue_new.save!
add_note_moved_from
end
def rewrite_notes
end
def close_old_issue
add_note_moved_to
end
def notify_participants
end
def add_note_moved_from
end
def add_note_moved_to
end
end
end
require 'spec_helper'
describe Issues::MoveService, services: true do
let(:user) { create(:user) }
let(:issue) { create(:issue, title: 'Some issue', description: 'Some issue description') }
let(:current_project) { issue.project }
let(:new_project) { create(:project) }
before do
current_project.team << [user, :master]
end
describe '#execute' do
let!(:new_issue) do
described_class.new(current_project, user).execute(issue, new_project)
end
it 'should create a new issue in a new project' do
expect(new_issue.project).to eq new_project
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment