diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-14 18:09:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-14 18:09:04 +0300 |
commit | a3dfd311f4660fc81e929058abd6e136ac884ed3 (patch) | |
tree | 4d7087cac6e2ca89df3adea98f92b9eddffa7790 /spec/views/shared | |
parent | 7f408a3831590a1f98a1e1a04b63acba8937e36b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/views/shared')
-rw-r--r-- | spec/views/shared/nav/_sidebar.html.haml_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/views/shared/nav/_sidebar.html.haml_spec.rb b/spec/views/shared/nav/_sidebar.html.haml_spec.rb new file mode 100644 index 00000000000..268d2952683 --- /dev/null +++ b/spec/views/shared/nav/_sidebar.html.haml_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'shared/nav/_sidebar.html.haml' do + let(:project) { build(:project, id: non_existing_record_id) } + let(:context) { Sidebars::Projects::Context.new(current_user: nil, container: project)} + let(:sidebar) { Sidebars::Projects::Panel.new(context) } + + before do + assign(:project, project) + assign(:sidebar, sidebar) + + allow(sidebar).to receive(:renderable_menus).and_return([]) + end + + context 'when sidebar has a scope menu' do + it 'renders the scope menu' do + render + + expect(rendered).to render_template('shared/nav/_scope_menu') + end + end + + context 'when sidebar does not have a scope menu' do + let(:scope_menu_view_path) { 'shared/nav/' } + let(:scope_menu_view_name) { 'scope_menu.html.haml' } + let(:scope_menu_view) { "#{scope_menu_view_path}#{scope_menu_view_name}" } + let(:scope_menu_partial) { "#{scope_menu_view_path}_#{scope_menu_view_name}" } + let(:content) { 'Custom test content' } + + context 'when sidebar has a custom scope menu partial defined' do + it 'renders the custom partial' do + allow(sidebar).to receive(:render_raw_scope_menu_partial).and_return(scope_menu_view) + allow(sidebar).to receive(:scope_menu).and_return(nil) + stub_template(scope_menu_partial => content) + + render + + expect(rendered).to have_text(content) + end + end + end +end |