Use documentable_attach_new_file method where possible
Use this commit to unify two similar specs.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user