Class: PlanMyStuff::TestingProjectItemsController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /testing_projects/:testing_project_id/items



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/plan_my_stuff/testing_project_items_controller.rb', line 11

def create
  project_number = params[:testing_project_id].to_i
  item = PMS::TestingProjectItem.create!(
    item_params[:title],
    draft: true,
    body: item_params[:body],
    project_number: project_number,
  )

  item.update_testers!(item_params[:testers]) if item_params[:testers].present?
  item.update_watchers!(item_params[:watchers]) if item_params[:watchers].present?
  item.update_due_date!(Date.parse(item_params[:due_date])) if item_params[:due_date].present?
  item.update_pass_mode!(item_params[:pass_mode]) if item_params[:pass_mode].present?

  flash[:success] = 'Item added.'
  redirect_to(plan_my_stuff.testing_project_path(project_number))
rescue ArgumentError, PMS::Error, Octokit::Error => e
  flash[:error] = e.message
  redirect_to(plan_my_stuff.testing_project_path(project_number))
end

#newObject

GET /testing_projects/:testing_project_id/items/new



6
7
8
# File 'app/controllers/plan_my_stuff/testing_project_items_controller.rb', line 6

def new
  @project = PMS::TestingProject.find(params[:testing_project_id].to_i)
end