Updates specs
This commit is contained in:
@@ -15,67 +15,53 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
|
||||
end
|
||||
end
|
||||
|
||||
context "Show documents tab" do
|
||||
context "Show documents" do
|
||||
|
||||
scenario "Download action should be able to anyone" do
|
||||
visit send(documentable_path, arguments)
|
||||
|
||||
within "#tab-documents" do
|
||||
expect(page).to have_link("Download 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: "Download 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: "Download file")
|
||||
end
|
||||
end
|
||||
|
||||
describe "Destroy action" do
|
||||
|
||||
scenario "Should not be able when no user logged in" do
|
||||
visit send(documentable_path, arguments)
|
||||
|
||||
within "#tab-documents" do
|
||||
expect(page).not_to have_link("Destroy")
|
||||
end
|
||||
expect(page).not_to have_link("Destroy document")
|
||||
end
|
||||
|
||||
scenario "Should be able when documentable author is logged in" do
|
||||
login_as documentable.author
|
||||
visit send(documentable_path, arguments)
|
||||
|
||||
within "#tab-documents" do
|
||||
expect(page).to have_link("Destroy")
|
||||
end
|
||||
expect(page).to have_link("Destroy document")
|
||||
end
|
||||
|
||||
scenario "Administrators cannot destroy documentables they have not authored" do
|
||||
login_as(administrator)
|
||||
visit send(documentable_path, arguments)
|
||||
|
||||
within "#tab-documents" do
|
||||
expect(page).not_to have_link("Destroy")
|
||||
end
|
||||
expect(page).not_to have_link("Destroy document")
|
||||
end
|
||||
|
||||
scenario "Users cannot destroy documentables they have not authored" do
|
||||
login_as(create(:user))
|
||||
visit send(documentable_path, arguments)
|
||||
|
||||
within "#tab-documents" do
|
||||
expect(page).not_to have_link("Destroy")
|
||||
end
|
||||
expect(page).not_to have_link("Destroy document")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -88,10 +74,9 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
|
||||
login_as documentable.author
|
||||
|
||||
visit send(documentable_path, arguments)
|
||||
within "#tab-documents" do
|
||||
|
||||
within "#document_#{document.id}" do
|
||||
click_on "Destroy"
|
||||
end
|
||||
click_on "Destroy document"
|
||||
end
|
||||
|
||||
expect(page).to have_content "Document was deleted successfully."
|
||||
@@ -101,23 +86,21 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
|
||||
login_as documentable.author
|
||||
|
||||
visit send(documentable_path, arguments)
|
||||
within "#tab-documents" do
|
||||
|
||||
within "#document_#{document.id}" do
|
||||
click_on "Destroy"
|
||||
end
|
||||
click_on "Destroy document"
|
||||
end
|
||||
|
||||
expect(page).to have_link "Documents (0)"
|
||||
expect(page).to have_content "Documents (0)"
|
||||
end
|
||||
|
||||
scenario "Should redirect to documentable path after successful deletion" do
|
||||
login_as documentable.author
|
||||
|
||||
visit send(documentable_path, arguments)
|
||||
within "#tab-documents" do
|
||||
|
||||
within "#document_#{document.id}" do
|
||||
click_on "Destroy"
|
||||
end
|
||||
click_on "Destroy document"
|
||||
end
|
||||
|
||||
within "##{dom_id(documentable)}" do
|
||||
|
||||
@@ -195,8 +195,6 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
documentable_redirected_to_resource_show_or_navigate_to
|
||||
|
||||
expect(page).to have_content "Documents"
|
||||
|
||||
find("#tab-documents-label").click
|
||||
expect(page).to have_content "empty.pdf"
|
||||
|
||||
# Review
|
||||
|
||||
Reference in New Issue
Block a user