Sha256: a4d005b441d7d6975b5dcb9b53c67f2912c85a68d2fb0329ffd3a7690c4454fa

Contents?: true

Size: 1.03 KB

Versions: 17

Compression:

Stored size: 1.03 KB

Contents

class TicketsController < ApplicationController
  before_filter :find_ticket, only: [:show, :update, :close, :reopen]

  attr_reader :ticket

  def show
    render json: FullTicketPresenter.new(ticket)
  end

  def update
    params[:last_release_at] = params.fetch(:lastReleaseAt, params[:last_release_at])
    attributes = params.pick(:last_release_at, :priority, :summary, :description)

    if ticket.update_attributes(attributes)
      render json: []
    else
      render json: ticket.errors, status: :unprocessable_entity
    end
  end

  def new
    @projects = followed_projects.select(&:has_ticket_tracker?)
  end

  def close
    authorize! :close, ticket
    ticket.close!
    render json: []
  rescue
    render json: [$!.message], status: :unprocessable_entity
  end

  def reopen
    authorize! :close, ticket
    ticket.reopen!
    render json: []
  rescue
    render json: [$!.message], status: :unprocessable_entity
  end

private

  def find_ticket
    @ticket = Ticket.find(params[:id])
    @ticket.updated_by = current_user
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

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