Skip to content

Commit 8f6c3ea

Browse files
committed
Add view request button to distribution row
- Only show if the distribution has a request
1 parent 9f91f82 commit 8f6c3ea

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

app/views/distributions/_distribution_row.html.erb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
<td class="date"><%= distribution_row.created_at.strftime("%m/%d/%Y") %></td>
55
<td class="date"><%= (distribution_row.issued_at.presence || distribution_row.created_at).strftime("%m/%d/%Y") %></td>
66
<td><%= distribution_row.storage_location.name %></td>
7-
87
<td class="numeric"><%= @distribution_totals[distribution_row.id].quantity %></td>
98
<td class="numeric"><%= dollar_value(@distribution_totals[distribution_row.id].value) %></td>
109
<td><%= distribution_row.delivery_method.humanize %></td>
1110
<td><%= distribution_shipping_cost(distribution_row.shipping_cost) %></td>
1211
<td><%= distribution_row.comment %></td>
1312
<td><%= distribution_row.state&.humanize %></td>
14-
1513
<% distribution_has_inactive_item = @distributions_with_inactive_items.include?(distribution_row.id) %>
1614
<td class="text-right">
1715
<%= view_button_to distribution_path(distribution_row) %>
16+
<% if distribution_row.request %>
17+
<%= view_button_to request_path(distribution_row.request), {icon: "eye", type: "secondary", text: "View Request"} %>
18+
<% end %>
1819
<% if (!distribution_row.complete? && !distribution_row.future?) || current_user.has_cached_role?(Role::ORG_ADMIN, current_organization) %>
1920
<%= edit_button_to edit_distribution_path(distribution_row), enabled: !distribution_has_inactive_item %>
2021
<% end %>

spec/system/distribution_system_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@
340340
context "With an existing distribution" do
341341
let!(:distribution) { create(:distribution, :with_items, agency_rep: "A Person", delivery_method: delivery_method, organization: user.organization, reminder_email_enabled: true) }
342342
let(:delivery_method) { "pick_up" }
343+
let!(:request) { create(:request, distribution: distribution) }
343344

344345
before do
345346
sign_in(organization_admin)
@@ -357,6 +358,12 @@
357358
expect(distribution.agency_rep).to eq("SOMETHING DIFFERENT")
358359
end
359360

361+
it "the user can view related request" do
362+
click_on "View Request"
363+
364+
expect(page).to have_content "Request from #{distribution.request.partner.name}"
365+
end
366+
360367
it "sends an email if reminders are enabled" do
361368
job = double('fake_job')
362369
allow(DistributionMailer).to receive(:reminder_email).and_return(job)

0 commit comments

Comments
 (0)