Class: Api::V1::TicketTasksController

Inherits:
ApplicationController show all
Defined in:
app/controllers/api/v1/ticket_tasks_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationController

#after_sign_in_path_for, #api_authenticate!, #current_project, #expire_revision!, #followed_projects, #no_cache, #read_revision, #require_login, #return_or_cache_revision!, #revision, #save_current_project, #set_current_project, #unfurling?

Methods included from UrlHelper

#edit_release_path, #edit_release_url, #feature_path, #github_commit_range_url, #github_commit_url, #github_project_url, #github_url?, #goldmine_case_number_url, #link_to_project_feature, #new_release_url, #release_path, #release_url, #releases_path

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



9
10
11
# File 'app/controllers/api/v1/ticket_tasks_controller.rb', line 9

def project
  @project
end

#taskObject (readonly)

Returns the value of attribute task.



9
10
11
# File 'app/controllers/api/v1/ticket_tasks_controller.rb', line 9

def task
  @task
end

#ticketObject (readonly)

Returns the value of attribute ticket.



9
10
11
# File 'app/controllers/api/v1/ticket_tasks_controller.rb', line 9

def ticket
  @ticket
end

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/api/v1/ticket_tasks_controller.rb', line 20

def create
  task = ticket.tasks.build params.slice(:description, :effort)
  authorize! :create, task

  task.updated_by = current_user
  if task.save
    render json: present_task(task), status: :created
  else
    render json: {errors: task.errors.full_messages}, status: :unprocessable_entity
  end
end

#destroyObject



44
45
46
47
48
49
# File 'app/controllers/api/v1/ticket_tasks_controller.rb', line 44

def destroy
  authorize! :destroy, task

  task.destroy
  head :ok
end

#indexObject



15
16
17
18
# File 'app/controllers/api/v1/ticket_tasks_controller.rb', line 15

def index
  authorize! :read, Task
  render json: ticket.tasks.map { |task| present_task(task) }
end

#updateObject



32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/api/v1/ticket_tasks_controller.rb', line 32

def update
  authorize! :update, task

  task.attributes = params.slice(:description, :effort)
  task.updated_by = current_user
  if task.save
    head :ok
  else
    render json: {errors: task.errors.full_messages}, status: :unprocessable_entity
  end
end