Regroup tests for edit path

This commit is contained in:
taitus
2024-11-26 16:55:25 +01:00
parent e450186122
commit c80641e5f2

View File

@@ -188,30 +188,20 @@ describe "Nested imageable" do
end end
context "Only for edit path" do context "Only for edit path" do
let(:factory) { :proposal } let(:proposal) { create(:proposal, :with_image, author: user) }
let(:path) { edit_proposal_path(imageable) }
before do scenario "handles image fields correctly" do
create(:image, imageable: imageable)
imageable.update!(author: user)
login_as(user) login_as(user)
visit path visit edit_proposal_path(proposal)
end
scenario "show persisted image" do
expect(page).to have_css ".image-fields", count: 1 expect(page).to have_css ".image-fields", count: 1
expect(page).not_to have_css "a#new_image_link" expect(page).not_to have_css "a#new_image_link"
end
scenario "remove nested field after removing the image" do
click_link "Remove image" click_link "Remove image"
expect(page).not_to have_css ".image-fields" expect(page).not_to have_css ".image-fields"
expect(page).to have_link id: "new_image_link" expect(page).to have_link id: "new_image_link"
end
scenario "don't duplicate fields after removing and adding an image" do
click_link "Remove image"
click_link "Add image" click_link "Add image"
expect(page).to have_css ".image-fields", count: 1, visible: :all expect(page).to have_css ".image-fields", count: 1, visible: :all