Commit fec8a11d authored by Paul Slaughter's avatar Paul Slaughter

Fix new dropdown showing on mobile with no items

- We needed to add a check for menu_sections
  which can be empty if the user is external and
  cannot create anything.
parent 0a6b560b
...@@ -22,7 +22,7 @@ module Nav ...@@ -22,7 +22,7 @@ module Nav
new_view_model = new_dropdown_view_model(project: project, group: group) new_view_model = new_dropdown_view_model(project: project, group: group)
if new_view_model if new_view_model && new_view_model.fetch(:menu_sections)&.any?
builder.add_view(NEW_VIEW, new_view_model) builder.add_view(NEW_VIEW, new_view_model)
end end
......
...@@ -539,10 +539,18 @@ RSpec.describe Nav::TopNavHelper do ...@@ -539,10 +539,18 @@ RSpec.describe Nav::TopNavHelper do
end end
context 'with new' do context 'with new' do
let(:with_new_view_model) { { id: 'test-new-view-model' } } let(:with_new_view_model) { { menu_sections: [{ id: 'test-new-view-model' }] } }
it 'has new subview' do it 'has new subview' do
expect(subject[:views][:new]).to eq({ id: 'test-new-view-model' }) expect(subject[:views][:new]).to eq(with_new_view_model)
end
end
context 'with new and no menu_sections' do
let(:with_new_view_model) { { menu_sections: [] } }
it 'has new subview' do
expect(subject[:views][:new]).to be_nil
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment