From d3d03d1362e576d194782a655cdfe9bc6ed5c596 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sun, 30 Aug 2015 21:51:34 -0700 Subject: Create a "destroyed Milestone" event and keep Milestone events around in the DB for posterity. Also fix issue where destroying a Milestone would cause odd, transient messages like "created milestone" or "imported milestone". Add "in" preposition when creating and destroying milestones Closes #2382 --- app/services/milestones/destroy_service.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 app/services/milestones/destroy_service.rb (limited to 'app/services/milestones') diff --git a/app/services/milestones/destroy_service.rb b/app/services/milestones/destroy_service.rb new file mode 100644 index 00000000000..7ce7d259d0b --- /dev/null +++ b/app/services/milestones/destroy_service.rb @@ -0,0 +1,22 @@ +module Milestones + class DestroyService < Milestones::BaseService + def execute(milestone) + + Milestone.transaction do + update_params = { milestone: nil } + milestone.issues.each do |issue| + Issues::UpdateService.new(project, current_user, update_params).execute(issue) + end + + event_service.destroy_milestone(milestone, current_user) + + Event.for_milestone_id(milestone.id).each do |event| + event.target_id = nil + event.save + end + + milestone.destroy + end + end + end +end -- cgit v1.2.1