Always expand the hierarchy in "favorite" mdoe

This commit is contained in:
Henriette Darge
2026-06-10 09:23:12 +02:00
parent a3bf582cea
commit 5a3eaa11e3
2 changed files with 10 additions and 1 deletions
@@ -162,7 +162,9 @@ class Header::ProjectsController < ApplicationController
def sort_nodes(nodes)
nodes.sort_by { |n| n[:project].name.downcase }.each do |node|
node[:children] = sort_nodes(node[:children])
node[:expanded] = node[:children].any? { |c| c[:project].id == @current_project_id || c[:expanded] }
node[:expanded] = filter_mode == "favorited" || node[:children].any? do |c|
c[:project].id == @current_project_id || c[:expanded]
end
end
end
end
@@ -103,6 +103,13 @@ RSpec.describe Header::ProjectsController do
make_request
expect(assigns(:favorited_ids)).to include(child_project.id)
end
it "marks parent nodes as expanded" do
make_request
tree = assigns(:tree)
parent_node = tree.find { |n| n[:project] == parent_project }
expect(parent_node[:expanded]).to be(true)
end
end
context "when the user has no favorites" do