Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion app/controllers/header/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@
sort_nodes(roots)
end

def sort_nodes(nodes)

Check warning on line 162 in app/controllers/header/projects_controller.rb

View workflow job for this annotation

GitHub Actions / RuboCop

[rubocop] reported by reviewdog 🐶 Assignment Branch Condition size for `sort_nodes` is too high. [<5, 15, 7> 17.29/17] Raw Output: app/controllers/header/projects_controller.rb:162:3: C: Metrics/AbcSize: Assignment Branch Condition size for `sort_nodes` is too high. [<5, 15, 7> 17.29/17]
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
7 changes: 7 additions & 0 deletions spec/controllers/header/projects_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@
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
Expand Down
Loading