Sha256: 9a140fe785e5772577769ae28ef324bcc1cf7e813f53128f450bc85e4476f1d8

Contents?: true

Size: 1.12 KB

Versions: 17

Compression:

Stored size: 1.12 KB

Contents

class SprintTaskLocksController < ApplicationController
  before_filter :authenticate_user!
  before_filter :find_sprint_and_task

  attr_reader :sprint, :task


  def create
    if sprint.completed?
      render json: {base: ["The Sprint is completed. You cannot check out or check in tasks."]}, status: :unprocessable_entity
      return
    end

    if task.checked_out?(sprint)
      render json: {base: ["Task ##{task.shorthand} is already checked out"]}, status: 422
    else
      task.check_out!(sprint, current_user)
      head :ok
    end
  end


  def destroy
    if sprint.completed?
      render json: {base: ["The Sprint is completed. You cannot check out or check in tasks."]}, status: :unprocessable_entity
      return
    end

    if task.checked_out_by_me?(sprint, current_user)
      task.check_in!(sprint)
      head :ok
    elsif task.checked_out?(sprint)
      render json: {base: ["Ticket ##{task.shorthand} is checked out. You cannot check it in"]}, status: 422
    else
      head :ok
    end
  end


private

  def find_sprint_and_task
    @sprint = Sprint.find params[:id]
    @task = Task.find params[:task_id]
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
houston-core-0.8.0.pre app/controllers/sprint_task_locks_controller.rb
houston-core-0.7.0 app/controllers/sprint_task_locks_controller.rb
houston-core-0.7.0.beta4 app/controllers/sprint_task_locks_controller.rb
houston-core-0.7.0.beta3 app/controllers/sprint_task_locks_controller.rb
houston-core-0.7.0.beta2 app/controllers/sprint_task_locks_controller.rb
houston-core-0.7.0.beta app/controllers/sprint_task_locks_controller.rb
houston-core-0.6.3 app/controllers/sprint_task_locks_controller.rb
houston-core-0.6.2 app/controllers/sprint_task_locks_controller.rb
houston-core-0.6.1 app/controllers/sprint_task_locks_controller.rb
houston-core-0.6.0 app/controllers/sprint_task_locks_controller.rb
houston-core-0.5.6 app/controllers/sprint_task_locks_controller.rb
houston-core-0.5.5 app/controllers/sprint_task_locks_controller.rb
houston-core-0.5.4 app/controllers/sprint_task_locks_controller.rb
houston-core-0.5.3 app/controllers/sprint_task_locks_controller.rb
houston-core-0.5.2 app/controllers/sprint_task_locks_controller.rb
houston-core-0.5.1 app/controllers/sprint_task_locks_controller.rb
houston-core-0.5.0 app/controllers/sprint_task_locks_controller.rb