From 47b1e0a4fd9876de06b1a5ac7eb008bad4addc16 Mon Sep 17 00:00:00 2001 From: Cory Streiff Date: Wed, 12 Mar 2025 12:11:55 +0100 Subject: [PATCH 1/2] Fix partners document upload bug --- app/views/partners/_form.html.erb | 12 +++++++++++- spec/system/partner_system_spec.rb | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/app/views/partners/_form.html.erb b/app/views/partners/_form.html.erb index be8d06a241..e798c975ba 100644 --- a/app/views/partners/_form.html.erb +++ b/app/views/partners/_form.html.erb @@ -47,7 +47,17 @@ <%= f.input_field :notes, class: "form-control" %> <% end %> <%= f.input :documents, label: "Documents", wrapper: :input_group do %> - <%= f.input_field :documents, as: :file, multiple: true, accept: Partner::ALLOWED_MIME_TYPES.join(","), class: "form-control h-auto" %> + <% if @partner.documents.present? %> + + <% end %> + <%= f.input_field :documents, as: :file, multiple: true, accept: Partner::ALLOWED_MIME_TYPES.join(","), class: "form-control-file h-auto" %> <% end %> diff --git a/spec/system/partner_system_spec.rb b/spec/system/partner_system_spec.rb index 4736fc044c..e8e143d3f1 100644 --- a/spec/system/partner_system_spec.rb +++ b/spec/system/partner_system_spec.rb @@ -378,6 +378,31 @@ partner.reload expect(partner.send_reminders).to be false end + + it "allows documents to be uploaded" do + document_1 = Rails.root.join("spec/fixtures/files/distribution_program_address.pdf") + document_2 = Rails.root.join("spec/fixtures/files/distribution_same_address.pdf") + documents = [document_1, document_2] + + # Upload the documents + visit subject + attach_file(documents, make_visible: true) do + page.find('input#partner_documents').click + end + + # Save Progress + click_button "Update Partner" + + # Expect documents to exist on show partner page + expect(page).to have_current_path(partner_path(partner.id)) + expect(page).to have_link("distribution_program_address.pdf") + expect(page).to have_link("distribution_same_address.pdf") + + # Expect documents to exist on edit partner page + visit subject + expect(page).to have_link("distribution_program_address.pdf") + expect(page).to have_link("distribution_same_address.pdf") + end end describe "#edit_profile" do From 2b5326341a0314ac9168ad27c96e57d45acec0d6 Mon Sep 17 00:00:00 2001 From: Cory Streiff Date: Fri, 14 Mar 2025 10:28:47 +0100 Subject: [PATCH 2/2] Fix styling to match other PR --- app/views/partners/_documents.html.erb | 30 ++++++++++---------------- app/views/partners/_form.html.erb | 14 ++++++------ 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/app/views/partners/_documents.html.erb b/app/views/partners/_documents.html.erb index 23b832e65e..c14894e6d2 100644 --- a/app/views/partners/_documents.html.erb +++ b/app/views/partners/_documents.html.erb @@ -2,25 +2,17 @@

Documents

-
-
- - - - - - - - - <% partner.documents.each do |document| %> - - - - <% end %> - -
Filename
<%= link_to document.filename, rails_blob_path(document, disposition: "attachment") %><%= delete_button_to attachment_path(document), { size: "md", confirm: "Are you sure you want to permanently remove this document?" } %> -
-
+
+
    + <% partner.documents.each do |doc| %> + <% if doc.persisted? %> +
  • + <%= link_to doc.blob.filename.to_s, rails_blob_path(doc), class: "font-weight-bold w-75 text-truncate" %> + <%= delete_button_to attachment_path(doc), { text: "Remove", size: "md", confirm: "Are you sure you want to permanently remove this document?" } %> +
  • + <% end %> + <% end %> +