Use documentable_attach_new_file method where possible

Use this commit to unify two similar specs.
This commit is contained in:
taitus
2025-05-16 11:16:02 +02:00
parent 64c1c59a7a
commit 82296a33e2
2 changed files with 10 additions and 23 deletions

View File

@@ -15,13 +15,14 @@ module Attachables
def documentable_attach_new_file(path, success: true)
click_link "Add new document"
attach_file "Choose document", path
within ".document-fields" do
if success
expect(page).to have_css ".loading-bar.complete"
else
expect(page).to have_css ".loading-bar.errors"
within "#nested-documents" do
attach_file "Choose document", path
within ".document-fields" do
if success
expect(page).to have_css ".loading-bar.complete"
else
expect(page).to have_css ".loading-bar.errors"
end
end
end
end

View File

@@ -85,27 +85,13 @@ describe "Nested documentable" do
expect(page).not_to have_css ".max-documents-notice"
end
scenario "Should update nested document file name after choosing a file" do
do_login_for(user, management: management_section?(path))
visit path
click_link "Add new document"
within "#nested-documents" do
attach_file "Choose document", file_fixture("empty.pdf")
expect(page).to have_css ".loading-bar.complete"
end
expect(page).to have_css ".file-name", text: "empty.pdf"
end
scenario "Should update nested document file title with
file name after choosing a file when no title defined" do
scenario "Should update file name and title after choosing a file with no title defined" do
do_login_for(user, management: management_section?(path))
visit path
documentable_attach_new_file(file_fixture("empty.pdf"))
expect(page).to have_css ".file-name", text: "empty.pdf"
expect_document_has_title(0, "empty.pdf")
end