diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /spec/models/sidebars/menu_spec.rb | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/models/sidebars/menu_spec.rb')
-rw-r--r-- | spec/models/sidebars/menu_spec.rb | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/spec/models/sidebars/menu_spec.rb b/spec/models/sidebars/menu_spec.rb deleted file mode 100644 index 320f5f1ad1e..00000000000 --- a/spec/models/sidebars/menu_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Sidebars::Menu do - let(:menu) { described_class.new(context) } - let(:context) { Sidebars::Context.new(current_user: nil, container: nil) } - - describe '#all_active_routes' do - it 'gathers all active routes of items and the current menu' do - menu_item1 = Sidebars::MenuItem.new(context) - menu_item2 = Sidebars::MenuItem.new(context) - menu_item3 = Sidebars::MenuItem.new(context) - menu.add_item(menu_item1) - menu.add_item(menu_item2) - menu.add_item(menu_item3) - - allow(menu).to receive(:active_routes).and_return({ path: 'foo' }) - allow(menu_item1).to receive(:active_routes).and_return({ path: %w(bar test) }) - allow(menu_item2).to receive(:active_routes).and_return({ controller: 'fooc' }) - allow(menu_item3).to receive(:active_routes).and_return({ controller: 'barc' }) - - expect(menu.all_active_routes).to eq({ path: %w(foo bar test), controller: %w(fooc barc) }) - end - - it 'does not include routes for non renderable items' do - menu_item = Sidebars::MenuItem.new(context) - menu.add_item(menu_item) - - allow(menu).to receive(:active_routes).and_return({ path: 'foo' }) - allow(menu_item).to receive(:render?).and_return(false) - allow(menu_item).to receive(:active_routes).and_return({ controller: 'bar' }) - - expect(menu.all_active_routes).to eq({ path: ['foo'] }) - end - end - - describe '#render?' do - context 'when the menus has no items' do - it 'returns true' do - expect(menu.render?).to be true - end - end - - context 'when the menu has items' do - let(:menu_item) { Sidebars::MenuItem.new(context) } - - before do - menu.add_item(menu_item) - end - - context 'when items are not renderable' do - it 'returns false' do - allow(menu_item).to receive(:render?).and_return(false) - - expect(menu.render?).to be false - end - end - - context 'when there are renderable items' do - it 'returns true' do - expect(menu.render?).to be true - end - end - end - end -end |