Class: TasksController

Inherits:
ApplicationController show all
Defined in:
app/controllers/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

#taskObject (readonly)

Returns the value of attribute task.



4
5
6
# File 'app/controllers/tasks_controller.rb', line 4

def task
  @task
end

Instance Method Details

#completeObject



18
19
20
21
22
23
24
# File 'app/controllers/tasks_controller.rb', line 18

def complete
  authorize! :update, task

  # !todo: authorize completing a task
  task.complete! unless task.completed?
  render json: TaskPresenter.new(task)
end

#reopenObject



26
27
28
29
30
31
32
# File 'app/controllers/tasks_controller.rb', line 26

def reopen
  authorize! :update, task

  # !todo: authorize completing a task
  task.reopen! unless task.open?
  render json: TaskPresenter.new(task)
end

#updateObject



6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/tasks_controller.rb', line 6

def update
  authorize! :update, task

  project = task.project
  effort = params[:effort]
  effort = effort.to_d if effort
  effort = nil if effort && effort <= 0
  task.updated_by = current_user
  task.update_attributes effort: effort
  render json: [], status: :ok
end