diff --git a/spec/shared/features/nested_documentable.rb b/spec/shared/features/nested_documentable.rb index 0733aa624..02dd1e54d 100644 --- a/spec/shared/features/nested_documentable.rb +++ b/spec/shared/features/nested_documentable.rb @@ -272,9 +272,18 @@ end def documentable_attach_new_file(path, success = true) click_link "Add new document" + document = all("#new_document").last document_input = document.find("input[type=file]", visible: false) - attach_file(document_input[:id], path, make_visible: true) + page.execute_script("$('##{document_input[:id]}').css('display','block')") + attach_file(document_input[:id], path, visible: true) + page.execute_script("$('##{document_input[:id]}').css('display','none')") + # Poltergeist is not removing this attribute after file upload at + # https://github.com/teampoltergeist/poltergeist/blob/master/lib/capybara/poltergeist/client/browser.coffee#L187 + # making https://github.com/teampoltergeist/poltergeist/blob/master/lib/capybara/poltergeist/client/browser.coffee#L186 + # always choose the previous used input. + page.execute_script("$('##{document_input[:id]}').removeAttr('_poltergeist_selected')") + within document do if success expect(page).to have_css ".loading-bar.complete"