Files
nairobi/app/controllers/documents_controller.rb
rgarcia dacc2d529d Fix destroy document specs
We were linking to the document url itself, which does not have a route
associated and so the specs fails

With this commit we are using the correct path to the destroy action of
the DocumentsController.

We are also using the referrer instead of a params[:from] attribute, as
it avoids having to pass an extra parameter, making the code prettier
and it works the same way
2019-01-24 21:39:43 +01:00

27 lines
642 B
Ruby

class DocumentsController < ApplicationController
before_action :authenticate_user!
load_and_authorize_resource
def destroy
respond_to do |format|
format.html do
if @document.destroy
flash[:notice] = t "documents.actions.destroy.notice"
else
flash[:alert] = t "documents.actions.destroy.alert"
end
redirect_to request.referer
end
format.js do
if @document.destroy
flash.now[:notice] = t "documents.actions.destroy.notice"
else
flash.now[:alert] = t "documents.actions.destroy.alert"
end
end
end
end
end