diff --git a/app/helpers/documents_helper.rb b/app/helpers/documents_helper.rb
index 4aab7a57c..7b681eec5 100644
--- a/app/helpers/documents_helper.rb
+++ b/app/helpers/documents_helper.rb
@@ -12,6 +12,12 @@ module DocumentsHelper
Hash[Document.sources.map { |k,v| [k, Document.human_attribute_name("document.#{k}")] }]
end
+ def document_link_url(document)
+ uri = URI.parse(document.link)
+ return document.link if uri.scheme == "http" || uri.scheme == "https"
+ "http://#{document.link}"
+ end
+
def bytesToMeg(bytes)
bytes / Numeric::MEGABYTE
end
diff --git a/app/views/documents/_document.html.erb b/app/views/documents/_document.html.erb
index 6a910385b..f9f3b3d9e 100644
--- a/app/views/documents/_document.html.erb
+++ b/app/views/documents/_document.html.erb
@@ -3,7 +3,11 @@
<%= document.title %>
- <%= link_to t('documents.buttons.download_document'), document.attachment.url, target: :blank, class: 'button hollow' %>
+ <%= link_to t('documents.buttons.download_document'),
+ document.attachment.url,
+ target: "_blank",
+ rel: "nofollow",
+ class: 'button hollow' %>
|
<% if can? :destroy, Document %>
diff --git a/config/locales/en/documents.yml b/config/locales/en/documents.yml
index 814eda091..b4f822e14 100644
--- a/config/locales/en/documents.yml
+++ b/config/locales/en/documents.yml
@@ -21,7 +21,7 @@ en:
notice: Document was deleted successfully.
alert: Cannot destroy document.
buttons:
- download_document: Download PDF
+ download_document: Dowload file
destroy_document: Destroy
errors:
messages:
diff --git a/config/locales/es/documents.yml b/config/locales/es/documents.yml
index 0dffcfbd1..a4b7daf89 100644
--- a/config/locales/es/documents.yml
+++ b/config/locales/es/documents.yml
@@ -21,7 +21,7 @@ es:
notice: "El documento se ha eliminado correctamente."
alert: "El documento no se ha podido eliminar."
buttons:
- download_document: Descargar PDF
+ download_document: Descargar archivo
destroy_document: Eliminar
errors:
messages:
diff --git a/spec/shared/features/documentable.rb b/spec/shared/features/documentable.rb
index 7ce6cc9a6..f8b0b4c1f 100644
--- a/spec/shared/features/documentable.rb
+++ b/spec/shared/features/documentable.rb
@@ -78,16 +78,28 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
end
end
- describe "Download action" do
+ scenario "Download action should be able to anyone" do
+ visit send(documentable_path, arguments)
- scenario "Should be able to anyone" do
- visit send(documentable_path, arguments)
-
- within "#tab-documents" do
- expect(page).to have_link("Download PDF")
- end
+ within "#tab-documents" do
+ expect(page).to have_link("Dowload file")
end
+ end
+ scenario "Download file link should have blank target attribute" do
+ visit send(documentable_path, arguments)
+
+ within "#tab-documents" do
+ expect(page).to have_selector("a[target=_blank]", text: "Dowload file")
+ end
+ end
+
+ scenario "Download file links should have rel attribute setted to no follow" do
+ visit send(documentable_path, arguments)
+
+ within "#tab-documents" do
+ expect(page).to have_selector("a[rel=nofollow]", text: "Dowload file")
+ end
end
describe "Destroy action" do
@@ -243,7 +255,7 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
within "#tab-documents" do
within "#document_#{Document.last.id}" do
expect(page).to have_content "Document title"
- expect(page).to have_link "Download PDF"
+ expect(page).to have_link "Dowload file"
expect(page).to have_link "Destroy"
end
end
|