Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4409] Only show fulfillment column if partner has default location #4466

Merged
Show file tree
Hide file tree
Changes from 4 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
11 changes: 9 additions & 2 deletions app/views/requests/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@
<tr>
<th>Item</th>
<th>Quantity</th>
<th>Fulfillment Location Inventory</th>
<% default_storage_location = @request.organization.default_storage_location ||
@request.partner.default_storage_location_id %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found one more thing on my last go-through -- and this is extremely nitpicky.
I think it would be better if we switched the two clauses in this or?

Why? You are only using the existence of a default storage location, but, If someone later decides to use the default storage location (say we decide to change the title) - it should match what we are using for getting the on_hand_for_location. In the probably rare case where the organization and partner both have default locations, we use the partner location.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I fixed it here 9e77b48

<% if default_storage_location %>
<th>Default storage location inventory</th>
<% end %>
<th>Total Inventory</th>
</tr>
</thead>
Expand All @@ -74,7 +78,9 @@
<tr>
<td><%= item.name %></td>
<td><%= item.quantity %></td>
<td><%= item.on_hand_for_location %></td>
<% if default_storage_location %>
<td><%= item.on_hand_for_location %></td>
<% end %>
<td><%= item.on_hand %></td>
</tr>
<% end %>
Expand All @@ -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' %>
</div>
</div>
</div>
</div>
Expand Down
28 changes: 28 additions & 0 deletions spec/requests/requests_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading