Class: TicketsController

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

#ticketObject (readonly)

Returns the value of attribute ticket.



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

def ticket
  @ticket
end

Instance Method Details

#closeObject



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

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

#newObject



21
22
23
# File 'app/controllers/tickets_controller.rb', line 21

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

#reopenObject



33
34
35
36
37
38
39
# File 'app/controllers/tickets_controller.rb', line 33

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

#showObject



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

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

#updateObject



10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/tickets_controller.rb', line 10

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