Class: Milestones::PromoteService

Inherits:
BaseService show all
Defined in:
app/services/milestones/promote_service.rb

Constant Summary collapse

PromoteMilestoneError =
Class.new(StandardError)

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #parent

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from Milestones::BaseService

Instance Method Details

#execute(milestone) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/services/milestones/promote_service.rb', line 7

def execute(milestone)
  check_project_milestone!(milestone)

  Milestone.transaction do
    group_milestone = clone_project_milestone(milestone)

    move_children_to_group_milestone(group_milestone)

    # Destroy all milestones with same title across projects
    destroy_old_milestones(milestone)

    # Rollback if milestone is not valid
    unless group_milestone.valid?
      raise_error(group_milestone.errors.full_messages.to_sentence)
    end

    group_milestone
  end
end