From dacc2d529dd96ffa0b55644eb4ad3b9cb01bda11 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 9 May 2018 18:59:35 +0200 Subject: [PATCH] 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 --- app/controllers/documents_controller.rb | 2 +- app/views/documents/_document.html.erb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 001d23446..1d6df8d14 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -11,7 +11,7 @@ class DocumentsController < ApplicationController else flash[:alert] = t "documents.actions.destroy.alert" end - redirect_to params[:from] + redirect_to request.referer end format.js do if @document.destroy diff --git a/app/views/documents/_document.html.erb b/app/views/documents/_document.html.erb index bf549e92b..9075bdd7c 100644 --- a/app/views/documents/_document.html.erb +++ b/app/views/documents/_document.html.erb @@ -13,7 +13,8 @@ <% if can?(:destroy, document) %>
<%= link_to t("documents.buttons.destroy_document"), - document_path(document, from: request.url), method: :delete, + document, + method: :delete, data: { confirm: t("documents.actions.destroy.confirm") }, class: "delete" %> <% end %>