From 3fd2a1f4988c69e3e2f89930dfa6027ef78dd1a7 Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 21 Nov 2024 15:06:27 +0100 Subject: [PATCH] Remove redirected_to_resource_show_or_navigate_to method This method was removed as its logic was redundant or unnecessary: - For "Proposal" new: After creating a proposal, we are redirected to the "created" page, where the text "Not now, go to my proposal" is not present, leading to a constant `rescue Capybara::ElementNotFound`. Instead, the "created" page shows a preview of how the proposal will look when published and a link saying "No, I want to publish the proposal". Since the click's purpose was to navigate to the proposal's "show" page, and this can already be verified on the "created" page, no additional handling is needed for this case. - For "Proposal" edit: After updating the proposal, we are directly redirected to the proposal's "show" page, so no click_link logic is necessary here either. - For "Budget": The redirection is now handled directly with: `visit edit_admin_budget_path(imageable) if factory == :budget`. --- spec/system/nested_imageable_spec.rb | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/spec/system/nested_imageable_spec.rb b/spec/system/nested_imageable_spec.rb index 900b7aeca..202f630cd 100644 --- a/spec/system/nested_imageable_spec.rb +++ b/spec/system/nested_imageable_spec.rb @@ -163,7 +163,7 @@ describe "Nested imageable" do expect(page).to have_content notice_text - redirected_to_resource_show_or_navigate_to(imageable) + visit edit_admin_budget_path(imageable) if factory == :budget expect(page).to have_css "figure img" expect(page).to have_css "figure figcaption" if show_caption_for?(factory) @@ -208,15 +208,6 @@ describe "Nested imageable" do factory != :budget end - def redirected_to_resource_show_or_navigate_to(imageable) - case imageable.class.to_s - when "Budget" - visit edit_admin_budget_path(Budget.last) - when "Proposal" - click_link "Not now, go to my proposal" rescue Capybara::ElementNotFound - end - end - def fill_in_required_fields return if edit_path?