Skip to content

Commit ab318c0

Browse files
authored
Merge pull request #5035 from danielabar/4821-part1-partner-profile-support-multiple-attached-docs
4821-part1-partner-profile-support-multiple-attached-docs
2 parents 1cb1990 + 59e0fb4 commit ab318c0

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

app/views/partners/profiles/step/_attached_documents_form.html.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
<strong>Attached files:</strong>
55
<ul>
66
<% profile.documents.each do |doc| %>
7-
<li><%= link_to doc.blob['filename'], rails_blob_path(doc), class: "font-weight-bold" %></li>
7+
<% if doc.persisted? %>
8+
<li><%= link_to doc.blob['filename'], rails_blob_path(doc), class: "font-weight-bold" %></li>
9+
<%= pf.hidden_field :documents, multiple: true, value: doc.signed_id %>
10+
<% end %>
811
<% end %>
912
</ul>
1013
<%= pf.file_field :documents, multiple: true, class: "form-control-file" %>

spec/fixtures/files/document1.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Food Pantry Program Overview
2+
3+
Our food pantry serves families in need within the community.
4+
5+
## Services Provided
6+
7+
- Weekly food distribution
8+
- Emergency food assistance
9+
10+
## Contact Information
11+
12+
13+
Phone: (555) 123-4567

spec/fixtures/files/document2.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Delivery Guidelines
2+
3+
Please follow these guidelines when delivering goods:
4+
5+
1. Ensure all packages are labeled.
6+
2. Deliveries must be completed by 5 PM.
7+
3. Contact us immediately if there are delays.
8+
9+
Thank you for your cooperation!

spec/system/partners/profile_edit_system_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,44 @@
9999
expect(page).to have_css("#partner_settings.accordion-collapse.collapse.show", visible: true)
100100
end
101101

102+
it "preserves previously uploaded documents when adding new attachments" do
103+
# Upload the first document
104+
find("button[data-bs-target='#attached_documents']").click
105+
expect(page).to have_css("#attached_documents.accordion-collapse.collapse.show", visible: true)
106+
107+
within "#attached_documents" do
108+
attach_file("partner_profile_documents", Rails.root.join("spec/fixtures/files/document1.md"), make_visible: true)
109+
end
110+
111+
# Save Progress
112+
all("input[type='submit'][value='Save Progress']").last.click
113+
expect(page).to have_css(".alert-success", text: "Details were successfully updated.")
114+
115+
# Verify the document is listed
116+
visit edit_partners_profile_path
117+
find("button[data-bs-target='#attached_documents']").click
118+
within "#attached_documents" do
119+
expect(page).to have_link("document1.md")
120+
end
121+
122+
# Upload a second document
123+
within "#attached_documents" do
124+
attach_file("partner_profile_documents", Rails.root.join("spec/fixtures/files/document2.md"), make_visible: true)
125+
end
126+
127+
# Save Progress
128+
all("input[type='submit'][value='Save Progress']").last.click
129+
expect(page).to have_css(".alert-success", text: "Details were successfully updated.")
130+
131+
# Verify both documents are listed
132+
visit edit_partners_profile_path
133+
find("button[data-bs-target='#attached_documents']").click
134+
within "#attached_documents" do
135+
expect(page).to have_link("document1.md")
136+
expect(page).to have_link("document2.md")
137+
end
138+
end
139+
102140
it "persists file upload when there are validation errors" do
103141
# Open up Agency Information section and upload proof-of-status letter
104142
find("button[data-bs-target='#agency_information']").click

0 commit comments

Comments
 (0)