Removed the now-unused 'documentable_fill_new_valid_proposal' method from common actions. Note that it does not seem necessary to create an administrator with the user, as was done in the original shared example. Also, as in the previous commit, it appears that we do not need to set the user as the author when creating the documentable. Also removed the documentable_redirected_to_resource_show_or_navigate_to method, which was only used for the :proposal factory but was not necessary. - In the "Proposal new" case (this commit), after submitting the form we are redirected to the "created" page, where the link "Not now, go to my proposal" does not appear. This caused the method to always raise a Capybara::ElementNotFound and return nil. Instead, this "created" page already displays a preview of the proposal and a link to publish it. Since we can verify that the proposal was created successfully here, no redirection or click is needed. - In the "Proposal edit" case (next commit), the user is redirected directly to the proposal's "show" page after update, so again, the method is unnecessary and has been removed.
25 lines
579 B
Ruby
25 lines
579 B
Ruby
module Documents
|
|
def documentable_attach_new_file(path, success = true)
|
|
click_link "Add new document"
|
|
|
|
document = all(".document-fields").last
|
|
attach_file "Choose document", path
|
|
|
|
within document do
|
|
if success
|
|
expect(page).to have_css ".loading-bar.complete"
|
|
else
|
|
expect(page).to have_css ".loading-bar.errors"
|
|
end
|
|
end
|
|
end
|
|
|
|
def expect_document_has_title(index, title)
|
|
document = all(".document-fields")[index]
|
|
|
|
within document do
|
|
expect(find("input[name$='[title]']").value).to eq title
|
|
end
|
|
end
|
|
end
|