Unify and move documentable shared specs to nested documentable file
This commit is contained in:
@@ -11,16 +11,6 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "Show documents" do
|
context "Show documents" do
|
||||||
scenario "Download action should be availabe to anyone and open in the same tab" do
|
|
||||||
visit send(documentable_path, arguments)
|
|
||||||
|
|
||||||
within "#documents" do
|
|
||||||
expect(page).to have_link text: document.title
|
|
||||||
expect(page).to have_css "a[rel=nofollow]", text: document.title
|
|
||||||
expect(page).not_to have_css "a[target=_blank]"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "Destroy action" do
|
describe "Destroy action" do
|
||||||
scenario "Should not be able when no user logged in" do
|
scenario "Should not be able when no user logged in" do
|
||||||
visit send(documentable_path, arguments)
|
visit send(documentable_path, arguments)
|
||||||
@@ -49,29 +39,6 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "When allow attached documents setting is enabled" do
|
|
||||||
before do
|
|
||||||
Setting["feature.allow_attached_documents"] = true
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Documents list should be available" do
|
|
||||||
login_as(user)
|
|
||||||
visit send(documentable_path, arguments)
|
|
||||||
|
|
||||||
expect(page).to have_css("#documents")
|
|
||||||
expect(page).to have_content("Documents (1)")
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Documents list increase documents number" do
|
|
||||||
create(:document, documentable: documentable, user: documentable.author)
|
|
||||||
login_as(user)
|
|
||||||
visit send(documentable_path, arguments)
|
|
||||||
|
|
||||||
expect(page).to have_css("#documents")
|
|
||||||
expect(page).to have_content("Documents (2)")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "When allow attached documents setting is disabled" do
|
describe "When allow attached documents setting is disabled" do
|
||||||
before do
|
before do
|
||||||
Setting["feature.allow_attached_documents"] = false
|
Setting["feature.allow_attached_documents"] = false
|
||||||
|
|||||||
@@ -198,11 +198,17 @@ describe "Nested documentable" do
|
|||||||
|
|
||||||
expect(page).to have_content notice_text
|
expect(page).to have_content notice_text
|
||||||
if factory != :dashboard_action
|
if factory != :dashboard_action
|
||||||
|
within "#documents" do
|
||||||
expect(page).to have_content "Documents (3)"
|
expect(page).to have_content "Documents (3)"
|
||||||
expect(page).to have_link href: /.pdf\Z/, count: 3
|
expect(page).to have_link href: /.pdf\Z/, count: 3
|
||||||
expect(page).to have_link text: "clippy.pdf"
|
|
||||||
expect(page).to have_link text: "empty.pdf"
|
expect(page).to have_link text: "empty.pdf"
|
||||||
|
expect(page).to have_css "a[rel=nofollow]"
|
||||||
|
expect(page).to have_link text: "clippy.pdf"
|
||||||
|
expect(page).to have_css "a[rel=nofollow]"
|
||||||
expect(page).to have_link text: "logo.pdf"
|
expect(page).to have_link text: "logo.pdf"
|
||||||
|
expect(page).to have_css "a[rel=nofollow]"
|
||||||
|
expect(page).not_to have_css "a[target=_blank]"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user