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
27 lines
642 B
Ruby
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
|