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
30 changes: 11 additions & 19 deletions app/views/partners/_documents.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,17 @@
<div class="card-header">
<h2 class="card-title fs-3">Documents</h2>
</div>
<div class="card-body p-0">
<div class="tab-content" id="custom-tabs-three-tabContent">
<table class="table">
<thead>
<tr>
<th>Filename</th>
<th></th>
</tr>
</thead>
<tbody>
<% partner.documents.each do |document| %>
<tr>
<td><%= link_to document.filename, rails_blob_path(document, disposition: "attachment") %></td>
<td><%= delete_button_to attachment_path(document), { size: "md", confirm: "Are you sure you want to permanently remove this document?" } %>
</tr>
<% end %>
</tbody>
</table>
</div><!-- /.box-body.table-responsive -->
<div class="card-body p-3">
<ul class="list-unstyled">
<% partner.documents.each do |doc| %>
<% if doc.persisted? %>
<li class="attached-document d-flex justify-content-between align-items-center p-2 border rounded mb-2" data-document-id="<%= doc.signed_id %>">
<%= 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?" } %>
</li>
<% end %>
<% end %>
</ul>
</div>
<!-- /.card-body -->
<div class="card-footer">
Expand Down
14 changes: 13 additions & 1 deletion app/views/partners/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,19 @@
<%= 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? %>
<ul class="list-unstyled w-100">
<% @partner.documents.each do |doc| %>
<% if doc.persisted? %>
<li class="attached-document d-flex justify-content-between align-items-center p-2 border rounded mb-2" data-document-id="<%= doc.signed_id %>">
<%= 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?" } %>
</li>
<% end %>
<% end %>
</ul>
<% end %>
<%= f.input_field :documents, as: :file, multiple: true, accept: Partner::ALLOWED_MIME_TYPES.join(","), class: "form-control-file h-auto" %>
<% end %>
</div>
<!-- /.card-body -->
Expand Down
25 changes: 25 additions & 0 deletions spec/system/partner_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down