Sha256: 5412c87905c35fe7560e0f8ba0f72d2e483996d6f9017773c134db74532bff77

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

class TestingNotesController < ApplicationController
  before_filter :find_ticket
  before_filter :find_testing_note, :only => [:destroy, :update]
  before_filter :authenticate_user!, :only => [:create, :update, :destroy]
  
  
  def create
    @testing_note = current_user.testing_notes.build(params[:testing_note].merge(project: @ticket.project))
    
    authorize! :create, @testing_note
    @testing_note.save
    render_testing_note
  end
  
  
  def update
    authorize! :update, @testing_note
    
    @testing_note.update_attributes(params[:testing_note])
    render_testing_note
  end
  
  
  def destroy
    authorize! :destroy, @testing_note
    
    @testing_note.destroy
    head 204
  end
  
  
private
  
  def find_ticket
    @ticket = Ticket.find(params[:ticket_id])
  end
  
  def find_testing_note
    @testing_note = @ticket.testing_notes.find(params[:id])
  end
  
  def render_testing_note
    if @testing_note.errors.any?
      render json: @testing_note.errors, :status => :unprocessable_entity
    else
      render json: TestingNotePresenter.new(@testing_note)
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
houston-core-0.5.0.beta1 app/controllers/testing_notes_controller.rb