diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-02-17 15:59:25 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-17 07:39:15 +0100 |
commit | c8e7d1ed8e3eafcc8234a0e6f443bf85369c8de1 (patch) | |
tree | 1b6e5cff95e648f2650b8bc7d062585ea637eead /app/services | |
parent | 11f817b3fda3f77da5fdfda787816fd36d4d98a6 (diff) | |
download | gitlab-ce-c8e7d1ed8e3eafcc8234a0e6f443bf85369c8de1.tar.gz |
Add issue move implementation to controller
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/issues/move_service.rb | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb index e2ab06ac332..935bd8a87f7 100644 --- a/app/services/issues/move_service.rb +++ b/app/services/issues/move_service.rb @@ -1,11 +1,20 @@ 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 + def initialize(project, current_user, params, issue) + super(project, current_user, params) + + @issue_old = issue + @issue_new = @issue_old.dup @project_old = @project + if params['move_to_project_id'] + @project_new = Project.find(params['move_to_project_id']) + end + end + + def execute + return unless move? + open_new_issue rewrite_notes close_old_issue @@ -14,8 +23,20 @@ module Issues @issue_new end + def move? + return false unless @project_new + return false unless @issue_new + return false unless can_move? + + true + end + private + def can_move? + true + end + def open_new_issue @issue_new.project = @project_new @issue_new.save! |