Skip to content

Commit

Permalink
Merge pull request #4466 from napster235/4409-only_show_fulfillment_c…
Browse files Browse the repository at this point in the history
…olumn_if_partner_has_default_location

[4409] Only show fulfillment column if partner has default location
  • Loading branch information
cielf committed Jun 27, 2024
2 parents 5c975a2 + 5e5aa72 commit 693c866
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
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.partner.default_storage_location_id ||
@request.organization.default_storage_location %>
<% 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
6 changes: 3 additions & 3 deletions spec/system/request_system_spec.rb
Original file line number Diff line number Diff line change
@@ -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") }
Expand Down Expand Up @@ -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}>")
Expand All @@ -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
Expand Down

0 comments on commit 693c866

Please sign in to comment.