Sha256: 9eed1efdad50eba91cb291296c917a91fd0f9b6929b2f221c77ef6d7357b2b03

Contents?: true

Size: 1.05 KB

Versions: 14

Compression:

Stored size: 1.05 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

14 entries across 14 versions & 1 rubygems

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