Commit 8a148793 authored by Robert Speicher's avatar Robert Speicher

Simplify Issue and MergeRequest UpdateServices

Now that those pesky task states are gone, these become a lot simpler.
parent 0e5fbb29
module Issues module Issues
class UpdateService < Issues::BaseService class UpdateService < Issues::BaseService
def execute(issue) def execute(issue)
state = params[:state_event] case params.delete(:state_event)
case state
when 'reopen' when 'reopen'
Issues::ReopenService.new(project, current_user, {}).execute(issue) Issues::ReopenService.new(project, current_user, {}).execute(issue)
when 'close' when 'close'
...@@ -16,7 +14,7 @@ module Issues ...@@ -16,7 +14,7 @@ module Issues
filter_params filter_params
old_labels = issue.labels.to_a old_labels = issue.labels.to_a
if params.present? && issue.update_attributes(params.except(:state_event)) if params.present? && issue.update_attributes(params)
issue.reset_events_cache issue.reset_events_cache
if issue.labels != old_labels if issue.labels != old_labels
......
...@@ -11,9 +11,7 @@ module MergeRequests ...@@ -11,9 +11,7 @@ module MergeRequests
params.except!(:target_project_id) params.except!(:target_project_id)
params.except!(:source_branch) params.except!(:source_branch)
state = params[:state_event] case params.delete(:state_event)
case state
when 'reopen' when 'reopen'
MergeRequests::ReopenService.new(project, current_user, {}).execute(merge_request) MergeRequests::ReopenService.new(project, current_user, {}).execute(merge_request)
when 'close' when 'close'
...@@ -26,9 +24,7 @@ module MergeRequests ...@@ -26,9 +24,7 @@ module MergeRequests
filter_params filter_params
old_labels = merge_request.labels.to_a old_labels = merge_request.labels.to_a
if params.present? && merge_request.update_attributes( if params.present? && merge_request.update_attributes(params)
params.except(:state_event)
)
merge_request.reset_events_cache merge_request.reset_events_cache
if merge_request.labels != old_labels if merge_request.labels != old_labels
......
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