Skip to content

Commit

Permalink
Rewrite group nav_left sheet to work also in specs
Browse files Browse the repository at this point in the history
  • Loading branch information
amaierhofer authored and carlobeltrame committed May 24, 2024
1 parent 8f20ba3 commit 2323a98
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
22 changes: 13 additions & 9 deletions app/helpers/sheet/group/nav_left.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) 2014-2021 Pfadibewegung Schweiz. This file is part of
# Copyright (c) 2014-2024 Pfadibewegung Schweiz. This file is part of
# hitobito and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito.
Expand Down Expand Up @@ -117,15 +117,19 @@ def render_deleted_people_link
end

def render_sub_layers
safe_join(grouped_sub_layers) do |type, layers|
layers = grouped_sub_layers.map do |type, layers|
content_tag(:li, content_tag(:span, type, class: 'divider')) +
safe_join(layers.map { |l| GroupDecorator.new(l) }) do |l|
l.use_hierarchy_from_parent(layer)
content_tag(:li, class: l.archived_class) do
link_to(l.display_name, active_path(l),
title: l.to_s, data: { turbo_submits_with: l.display_name })
end
end
safe_join(layers.map { |l| render_sub_layer(l.decorate) })

end
safe_join(layers)
end

def render_sub_layer(l)
l.use_hierarchy_from_parent(layer)
content_tag(:li, class: l.archived_class) do
link_to(l.display_name, active_path(l),
title: l.to_s, data: { turbo_submits_with: l.display_name })
end
end

Expand Down
10 changes: 4 additions & 6 deletions spec/helpers/sheet/group/nav_left_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2012-2014, Pfadibewegung Schweiz. This file is part of
# Copyright (c) 2012-2024, Pfadibewegung Schweiz. This file is part of
# hitobito and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito.
Expand Down Expand Up @@ -46,11 +46,9 @@ def can?(*_args)
is_expected.to_not have_link('TP', text: 'TP')
end

# TODO: safe_join of this test's view does not behave as it should
# it 'displays sub layer with short name if available' do
# is_expected.to have_link('One', text: 'One')
# is_expected.to_not have_link('Bottom One', text: 'Bottom One')
# end
it 'displays sub layer' do
is_expected.to have_link('Bottom One', text: 'Bottom One')
end

it 'displays group with short name if available' do
is_expected.to have_link('TG', text: 'TG')
Expand Down

0 comments on commit 2323a98

Please sign in to comment.