Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
<strong>Attached files:</strong>
<ul>
<% profile.documents.each do |doc| %>
<li><%= link_to doc.blob['filename'], rails_blob_path(doc), class: "font-weight-bold" %></li>
<% if doc.persisted? %>
<li><%= link_to doc.blob['filename'], rails_blob_path(doc), class: "font-weight-bold" %></li>
<%= pf.hidden_field :documents, multiple: true, value: doc.signed_id %>
<% end %>
<% end %>
</ul>
<%= pf.file_field :documents, multiple: true, class: "form-control-file" %>
Expand Down
13 changes: 13 additions & 0 deletions spec/fixtures/files/document1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Food Pantry Program Overview

Our food pantry serves families in need within the community.

## Services Provided

- Weekly food distribution
- Emergency food assistance

## Contact Information

Email: info@foodpantry.org
Phone: (555) 123-4567
9 changes: 9 additions & 0 deletions spec/fixtures/files/document2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Delivery Guidelines

Please follow these guidelines when delivering goods:

1. Ensure all packages are labeled.
2. Deliveries must be completed by 5 PM.
3. Contact us immediately if there are delays.

Thank you for your cooperation!
38 changes: 38 additions & 0 deletions spec/system/partners/profile_edit_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,44 @@
expect(page).to have_css("#partner_settings.accordion-collapse.collapse.show", visible: true)
end

it "preserves previously uploaded documents when adding new attachments" do
# Upload the first document
find("button[data-bs-target='#attached_documents']").click
expect(page).to have_css("#attached_documents.accordion-collapse.collapse.show", visible: true)

within "#attached_documents" do
attach_file("partner_profile_documents", Rails.root.join("spec/fixtures/files/document1.md"), make_visible: true)
end

# Save Progress
all("input[type='submit'][value='Save Progress']").last.click
expect(page).to have_css(".alert-success", text: "Details were successfully updated.")

# Verify the document is listed
visit edit_partners_profile_path
find("button[data-bs-target='#attached_documents']").click
within "#attached_documents" do
expect(page).to have_link("document1.md")
end

# Upload a second document
within "#attached_documents" do
attach_file("partner_profile_documents", Rails.root.join("spec/fixtures/files/document2.md"), make_visible: true)
end

# Save Progress
all("input[type='submit'][value='Save Progress']").last.click
expect(page).to have_css(".alert-success", text: "Details were successfully updated.")

# Verify both documents are listed
visit edit_partners_profile_path
find("button[data-bs-target='#attached_documents']").click
within "#attached_documents" do
expect(page).to have_link("document1.md")
expect(page).to have_link("document2.md")
end
end

it "persists file upload when there are validation errors" do
# Open up Agency Information section and upload proof-of-status letter
find("button[data-bs-target='#agency_information']").click
Expand Down