Unify and move documentable shared specs to nested documentable file

This commit is contained in:
taitus
2025-05-19 10:38:48 +02:00
parent 11f09c281c
commit 7a317ef9c1
2 changed files with 11 additions and 38 deletions

View File

@@ -11,16 +11,6 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
end
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
scenario "Should not be able when no user logged in" do
visit send(documentable_path, arguments)
@@ -49,29 +39,6 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
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
before do
Setting["feature.allow_attached_documents"] = false

View File

@@ -198,11 +198,17 @@ describe "Nested documentable" do
expect(page).to have_content notice_text
if factory != :dashboard_action
expect(page).to have_content "Documents (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: "logo.pdf"
within "#documents" do
expect(page).to have_content "Documents (3)"
expect(page).to have_link href: /.pdf\Z/, count: 3
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_css "a[rel=nofollow]"
expect(page).not_to have_css "a[target=_blank]"
end
end
end