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}")] }]
|
||||
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
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
<%= document.title %>
|
||||
</td>
|
||||
<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 class="text-center">
|
||||
<% if can? :destroy, Document %>
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user