Skip to content

Commit

Permalink
[4522] Fix items order in inventory adjustment dropdown. (#4541)
Browse files Browse the repository at this point in the history
* [4522] Fix items order in inventory adjustment dropdown.

* Sort inventory items alphabetically and add corresponding test.
  • Loading branch information
amanbhargav authored Aug 1, 2024
1 parent 35ab604 commit 9916e0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/storage_locations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def inventory
.active

@inventory_items += include_omitted_items(@inventory_items.collect(&:item_id)) if params[:include_omitted_items] == "true"
@inventory_items.to_a.sort_by! { |inventory_item| inventory_item.item.name.downcase }
respond_to :json
end
end
Expand Down
6 changes: 6 additions & 0 deletions spec/requests/storage_locations_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,12 @@ def item_to_h(view_item)
expect(response.parsed_body).to eq(items_at_storage_location)
expect(response.parsed_body).to eq(inventory_items_at_storage_location)
end

it "returns items sorted alphabetically by item name" do
get inventory_storage_location_path(storage_location, format: :json)
sorted_items = inventory_items_at_storage_location.sort_by { |item| item['item_name'].downcase }
expect(response.parsed_body).to eq(sorted_items)
end
end

context "when also including inactive items" do
Expand Down

0 comments on commit 9916e0f

Please sign in to comment.