Class: PlanMyStuff::Issues::TakesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/plan_my_stuff/issues/takes_controller.rb

Overview

Moves an issue’s pipeline ProjectItem to “Started” via PlanMyStuff::Pipeline.take!. Backs the “Take” button on the mounted issue show view (T-RC-017). The primary UI path for a dev picking up work on an issue they’ve been assigned to.

Instance Method Summary collapse

Instance Method Details

#createObject

POST /issues/:issue_id/take



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/plan_my_stuff/issues/takes_controller.rb', line 13

def create
  issue = PlanMyStuff::Issue.find(params[:issue_id])
  guard_already_taken!(issue)

  project_item = PlanMyStuff::Pipeline::IssueLinker.find_project_item(issue.number)
  project_item ||= add_to_pipeline(issue)

  PlanMyStuff::Pipeline.take!(project_item)
  assign_current_user(project_item)

  yield(project_item) if block_given?
  return if performed?

  flash[:success] ||= "Issue ##{issue.number} taken."

  redirect_to(plan_my_stuff.issue_path(issue))
rescue ArgumentError, PlanMyStuff::Error => e
  pms_handle_rescue(e)
  flash[:error] = e.message
  redirect_to(plan_my_stuff.issue_path(params[:issue_id]))
end

#destroyObject

DELETE /issues/:issue_id/take



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/controllers/plan_my_stuff/issues/takes_controller.rb', line 36

def destroy
  issue = PlanMyStuff::Issue.find(params[:issue_id])
   = 
  guard_release!(issue, )

  remaining = issue.assignees - []
  project_item = PlanMyStuff::Pipeline::IssueLinker.find_project_item(issue.number)

  if project_item.present?
    if remaining.empty?
      issue.update!(assignees: [])
      project_item.destroy!
    else
      project_item.assign!(remaining)
    end
  else
    issue.update!(assignees: remaining)
  end

  yielded = project_item.presence || issue
  yield(yielded) if block_given?
  return if performed?

  flash[:success] = "Issue ##{issue.number} released."
  redirect_to(plan_my_stuff.issue_path(issue))
rescue ArgumentError, PlanMyStuff::Error => e
  pms_handle_rescue(e)
  flash[:error] = e.message
  redirect_to(plan_my_stuff.issue_path(params[:issue_id]))
end