Class: PlanMyStuff::TestingProjectItems::ResultsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/plan_my_stuff/testing_project_items/results_controller.rb

Overview

Handles Pass/Fail outcomes for testing project items.

Pass is submitted directly via button_to with result: “pass”. Fail renders a form (new) to capture result_notes before posting to create.

Instance Method Summary collapse

Instance Method Details

#createObject

POST /testing_projects/:testing_project_id/items/:item_id/result



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/plan_my_stuff/testing_project_items/results_controller.rb', line 18

def create
  project_number = params[:testing_project_id].to_i
  item = find_project_item(project_number)

  if params[:result] == 'pass'
    item.mark_passed!(pms_current_user)
    flash[:success] = 'Item marked as Passed.'
  else
    item.mark_failed!(pms_current_user, result_notes: params[:result_notes])
    flash[:success] = 'Item marked as Failed.'
  end

  redirect_to(plan_my_stuff.testing_project_path(project_number))
rescue PMS::ValidationError => e
  flash.now[:error] = e.message
  @project_number = params[:testing_project_id].to_i
  @item_id = params[:item_id]
  render(:new, status: PMS.unprocessable_status)
rescue ArgumentError, PMS::Error, Octokit::Error => e
  flash[:error] = e.message
  redirect_to(plan_my_stuff.testing_project_path(params[:testing_project_id].to_i))
end

#newObject

GET /testing_projects/:testing_project_id/items/:item_id/result/new



12
13
14
15
# File 'app/controllers/plan_my_stuff/testing_project_items/results_controller.rb', line 12

def new
  @project_number = params[:testing_project_id].to_i
  @item_id = params[:item_id]
end