Add rel attribute with nofollow value.
This commit is contained in:
@@ -12,6 +12,12 @@ module DocumentsHelper
|
|||||||
Hash[Document.sources.map { |k,v| [k, Document.human_attribute_name("document.#{k}")] }]
|
Hash[Document.sources.map { |k,v| [k, Document.human_attribute_name("document.#{k}")] }]
|
||||||
end
|
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)
|
def bytesToMeg(bytes)
|
||||||
bytes / Numeric::MEGABYTE
|
bytes / Numeric::MEGABYTE
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
<%= document.title %>
|
<%= document.title %>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<%= 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' %>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<% if can? :destroy, Document %>
|
<% if can? :destroy, Document %>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ en:
|
|||||||
notice: Document was deleted successfully.
|
notice: Document was deleted successfully.
|
||||||
alert: Cannot destroy document.
|
alert: Cannot destroy document.
|
||||||
buttons:
|
buttons:
|
||||||
download_document: Download PDF
|
download_document: Dowload file
|
||||||
destroy_document: Destroy
|
destroy_document: Destroy
|
||||||
errors:
|
errors:
|
||||||
messages:
|
messages:
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ es:
|
|||||||
notice: "El documento se ha eliminado correctamente."
|
notice: "El documento se ha eliminado correctamente."
|
||||||
alert: "El documento no se ha podido eliminar."
|
alert: "El documento no se ha podido eliminar."
|
||||||
buttons:
|
buttons:
|
||||||
download_document: Descargar PDF
|
download_document: Descargar archivo
|
||||||
destroy_document: Eliminar
|
destroy_document: Eliminar
|
||||||
errors:
|
errors:
|
||||||
messages:
|
messages:
|
||||||
|
|||||||
@@ -78,16 +78,28 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
|
|||||||
end
|
end
|
||||||
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
|
within "#tab-documents" do
|
||||||
visit send(documentable_path, arguments)
|
expect(page).to have_link("Dowload file")
|
||||||
|
|
||||||
within "#tab-documents" do
|
|
||||||
expect(page).to have_link("Download PDF")
|
|
||||||
end
|
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "Destroy action" do
|
describe "Destroy action" do
|
||||||
@@ -243,7 +255,7 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
|
|||||||
within "#tab-documents" do
|
within "#tab-documents" do
|
||||||
within "#document_#{Document.last.id}" do
|
within "#document_#{Document.last.id}" do
|
||||||
expect(page).to have_content "Document title"
|
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"
|
expect(page).to have_link "Destroy"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user