Skip to content

Commit a785627

Browse files
Fix idempotency issue during partner info upload (#5304)
1 parent 654f9f2 commit a785627

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

app/views/partners/_form.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<% if doc.persisted? %>
5454
<li class="attached-document d-flex justify-content-between align-items-center p-2 border rounded mb-2" data-document-id="<%= doc.signed_id %>">
5555
<%= link_to doc.blob.filename.to_s, rails_blob_path(doc), class: "font-weight-bold w-75 text-truncate" %>
56+
<%= f.hidden_field :documents, multiple: true, value: doc.signed_id %>
5657
<%= delete_button_to attachment_path(doc), { text: "Remove", size: "md", confirm: "Are you sure you want to permanently remove this document?" } %>
5758
</li>
5859
<% end %>

spec/system/partner_system_spec.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,34 @@
403403
expect(page).to have_link("distribution_program_address.pdf")
404404
expect(page).to have_link("distribution_same_address.pdf")
405405
end
406+
407+
it "allows documents to be uploaded and persists documents across multiple refreshes", :aggregate_failures do
408+
document_1 = Rails.root.join("spec/fixtures/files/distribution_program_address.pdf")
409+
document_2 = Rails.root.join("spec/fixtures/files/distribution_same_address.pdf")
410+
documents = [document_1, document_2]
411+
412+
# Upload the documents
413+
visit subject
414+
attach_file(documents, make_visible: true) do
415+
page.find('input#partner_documents').click
416+
end
417+
418+
# Test document persistence across multiple refresh cycles
419+
3.times do |iteration|
420+
# Save progress
421+
click_button "Update Partner"
422+
423+
# Verify documents on show page
424+
expect(page).to have_current_path(partner_path(partner.id))
425+
expect(page).to have_link("distribution_program_address.pdf")
426+
expect(page).to have_link("distribution_same_address.pdf")
427+
428+
# Visit edit page and verify documents persist
429+
visit subject
430+
expect(page).to have_link("distribution_program_address.pdf")
431+
expect(page).to have_link("distribution_same_address.pdf")
432+
end
433+
end
406434
end
407435

408436
describe "#edit_profile" do

0 commit comments

Comments
 (0)