diff --git a/app/views/requests/show.html.erb b/app/views/requests/show.html.erb
index f7e4ab98b1..7d5c48c57b 100644
--- a/app/views/requests/show.html.erb
+++ b/app/views/requests/show.html.erb
@@ -65,7 +65,11 @@
Item |
Quantity |
- Fulfillment Location Inventory |
+ <% default_storage_location = @request.partner.default_storage_location_id ||
+ @request.organization.default_storage_location %>
+ <% if default_storage_location %>
+ Default storage location inventory |
+ <% end %>
Total Inventory |
@@ -74,7 +78,9 @@
<%= item.name %> |
<%= item.quantity %> |
- <%= item.on_hand_for_location %> |
+ <% if default_storage_location %>
+ <%= item.on_hand_for_location %> |
+ <% end %>
<%= item.on_hand %> |
<% end %>
@@ -94,6 +100,7 @@
<%= view_button_to(distribution_path(@request.distribution), {text: "View Associated Distribution", size: "md"}) if @request.distribution %>
<%= button_to 'Cancel', new_request_cancelation_path(request_id: @request.id),
method: :get, form_class: 'd-inline', class: 'btn btn-danger btn-md' %>
+
diff --git a/spec/requests/requests_requests_spec.rb b/spec/requests/requests_requests_spec.rb
index 0864626837..162ad9adde 100644
--- a/spec/requests/requests_requests_spec.rb
+++ b/spec/requests/requests_requests_spec.rb
@@ -48,6 +48,34 @@
expect(response).to have_http_status(:not_found)
end
end
+
+ context 'When organization has a default storage location' do
+ let(:request) { create(:request, organization: create(:organization, default_storage_location: 1)) }
+ it 'shows the column Default storage location inventory' do
+ get request_path(request)
+
+ expect(response.body).to include('Default storage location inventory')
+ end
+ end
+
+ context 'When partner has a default storage location' do
+ let(:storage_location) { create(:storage_location) }
+ let(:request) { create(:request, partner: create(:partner, default_storage_location_id: storage_location.id)) }
+ it 'shows the column Default storage location inventory' do
+ get request_path(request)
+
+ expect(response.body).to include('Default storage location inventory')
+ end
+ end
+
+ context 'When neither partner nor organization has a default storage location' do
+ let(:request) { create(:request, organization: organization) }
+ it 'does not show the column Default storage location inventory' do
+ get request_path(request)
+
+ expect(response.body).not_to include('Default storage location inventory')
+ end
+ end
end
describe 'POST #start' do
diff --git a/spec/system/request_system_spec.rb b/spec/system/request_system_spec.rb
index 03d73c4cfd..7d9bfe468a 100644
--- a/spec/system/request_system_spec.rb
+++ b/spec/system/request_system_spec.rb
@@ -1,5 +1,5 @@
RSpec.describe "Requests", type: :system, js: true do
- let(:organization) { create(:organization) }
+ let(:organization) { create(:organization, default_storage_location: 1) }
let(:user) { create(:user, organization: organization) }
let(:item1) { create(:item, name: "Good item") }
@@ -133,7 +133,7 @@
it "should show the request with a request sender if a partner user is set" do
visit subject
expect(page).to have_content("Request from #{request.partner.name}")
- expect(page).to have_content("Fulfillment Location Inventory")
+ expect(page).to have_content("Default storage location inventory")
expect(page).to have_content("Request Sender:")
partner_user = request.partner_user
expect(page).to have_content("#{partner_user.name} <#{partner_user.email}>")
@@ -145,7 +145,7 @@
request.save!
visit subject
expect(page).to have_content("Request from #{request.partner.name}")
- expect(page).to have_content("Fulfillment Location Inventory")
+ expect(page).to have_content("Default storage location inventory")
expect(page).to have_content("Request Sender:")
expect(page).not_to have_content("#{partner_user.name} <#{partner_user.email}>")
end