From 4318b371b065559ac729219e7f8c65a4048bd43a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 29 Mar 2022 21:17:02 +0200 Subject: [PATCH] Add expectations after submit in attachments specs There were cases where we clicked the button to submit the form and immediately we visited a different page. In the past, we've had similar code produce PG::ProtocolViolation errors in similar situations. Since we've had these errors a few times in the nested imageable specs, there's a chance they're related to the absence of the expectation. Although I'm not even remotely sure this will fix these issues, at least we now follow the convention of making expectations after every request. Note we're changing both the nested imageable and nested documentable specs. Only the nested imageable would need to be changed because it's the one where there's a `visit` inside the `imageable_redirected_to_resource_show_or_navigate_to` method. I'm changing both for consistency. --- spec/shared/system/nested_documentable.rb | 5 +++++ spec/shared/system/nested_imageable.rb | 3 +++ 2 files changed, 8 insertions(+) diff --git a/spec/shared/system/nested_documentable.rb b/spec/shared/system/nested_documentable.rb index dafc01796..08225a442 100644 --- a/spec/shared/system/nested_documentable.rb +++ b/spec/shared/system/nested_documentable.rb @@ -210,6 +210,8 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na documentable_attach_new_file(file_fixture("empty.pdf")) click_on submit_button + expect(page).to have_content documentable_success_notice + documentable_redirected_to_resource_show_or_navigate_to expect(page).to have_content "Documents" @@ -232,6 +234,9 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na end click_on submit_button + + expect(page).to have_content documentable_success_notice + documentable_redirected_to_resource_show_or_navigate_to expect(page).to have_content "Documents (#{documentable.class.max_documents_allowed})" diff --git a/spec/shared/system/nested_imageable.rb b/spec/shared/system/nested_imageable.rb index 1d6d1899e..f82b66abb 100644 --- a/spec/shared/system/nested_imageable.rb +++ b/spec/shared/system/nested_imageable.rb @@ -184,6 +184,9 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p expect(page).to have_selector ".loading-bar.complete" click_on submit_button + + expect(page).to have_content imageable_success_notice + imageable_redirected_to_resource_show_or_navigate_to(imageable) expect(page).to have_selector "figure img"