Class: PlanMyStuff::Issues::TestingsController

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

Overview

Toggles the pipeline Testing custom field on an issue’s project item via PlanMyStuff::Pipeline.request_testing! and PlanMyStuff::Pipeline.clear_testing!. Backs the “Request testing” / “Clear testing” buttons on the mounted issue show view.

POST /issues/:issue_id/testing -> create (flips Testing to its active value) DELETE /issues/:issue_id/testing -> destroy (flips Testing back to inactive)

Instance Method Summary collapse

Instance Method Details

#createObject

POST /issues/:issue_id/testing



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

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

  PlanMyStuff::Pipeline.request_testing!(project_item, user: pms_current_user)

  yield(project_item) if block_given?
  return if performed?

  flash[:success] = "Issue ##{issue.number} marked as in testing."
  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/testing



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/plan_my_stuff/issues/testings_controller.rb', line 34

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

  PlanMyStuff::Pipeline.clear_testing!(project_item, user: pms_current_user)

  yield(project_item) if block_given?
  return if performed?

  flash[:success] = "Issue ##{issue.number} testing cleared."
  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