Skip to content

Commit 47b1e0a

Browse files
committed
Fix partners document upload bug
1 parent 98ab422 commit 47b1e0a

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

app/views/partners/_form.html.erb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,17 @@
4747
<%= f.input_field :notes, class: "form-control" %>
4848
<% end %>
4949
<%= f.input :documents, label: "Documents", wrapper: :input_group do %>
50-
<%= f.input_field :documents, as: :file, multiple: true, accept: Partner::ALLOWED_MIME_TYPES.join(","), class: "form-control h-auto" %>
50+
<% if @partner.documents.present? %>
51+
<ul class="list-unstyled">
52+
<% @partner.documents.each do |document| %>
53+
<li>
54+
<%= link_to document.blob['filename'], rails_blob_path(document), disposition: "attachment", class: "p1-1" %>
55+
<%= delete_button_to attachment_path(document), { text: "", confirm: "Are you sure you want to permanently remove this document?" } %>
56+
</li>
57+
<% end %>
58+
</ul>
59+
<% end %>
60+
<%= f.input_field :documents, as: :file, multiple: true, accept: Partner::ALLOWED_MIME_TYPES.join(","), class: "form-control-file h-auto" %>
5161
<% end %>
5262
</div>
5363
<!-- /.card-body -->

spec/system/partner_system_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,31 @@
378378
partner.reload
379379
expect(partner.send_reminders).to be false
380380
end
381+
382+
it "allows documents to be uploaded" do
383+
document_1 = Rails.root.join("spec/fixtures/files/distribution_program_address.pdf")
384+
document_2 = Rails.root.join("spec/fixtures/files/distribution_same_address.pdf")
385+
documents = [document_1, document_2]
386+
387+
# Upload the documents
388+
visit subject
389+
attach_file(documents, make_visible: true) do
390+
page.find('input#partner_documents').click
391+
end
392+
393+
# Save Progress
394+
click_button "Update Partner"
395+
396+
# Expect documents to exist on show partner page
397+
expect(page).to have_current_path(partner_path(partner.id))
398+
expect(page).to have_link("distribution_program_address.pdf")
399+
expect(page).to have_link("distribution_same_address.pdf")
400+
401+
# Expect documents to exist on edit partner page
402+
visit subject
403+
expect(page).to have_link("distribution_program_address.pdf")
404+
expect(page).to have_link("distribution_same_address.pdf")
405+
end
381406
end
382407

383408
describe "#edit_profile" do

0 commit comments

Comments
 (0)