diff options
author | Luke Bennett <lbennett@gitlab.com> | 2019-01-30 04:42:50 +0000 |
---|---|---|
committer | Ezekiel Kigbo <ekigbo@gitlab.com> | 2019-03-05 00:58:21 +1100 |
commit | 6b3966407baff221a0f1f9019fba34c29bafa087 (patch) | |
tree | c294bce622f52739f2daabe1aef86c01f3046b5e /spec | |
parent | fde3f619ba557d5242b4fec07488b05398b4993d (diff) | |
download | gitlab-ce-6b3966407baff221a0f1f9019fba34c29bafa087.tar.gz |
Add tests for nav sidebar collapsed on render
Adds rspec view tests that expect the nav sidebar
to have a class that will cause the nav sidebar
to be rendered collapsed with or without js.
Tests the nav sidebar on the admin, group,
instance statistics, user profile and project
sidebars.
Diffstat (limited to 'spec')
6 files changed, 46 insertions, 0 deletions
diff --git a/spec/support/shared_examples/views/nav_sidebar.rb b/spec/support/shared_examples/views/nav_sidebar.rb new file mode 100644 index 00000000000..3e709c8ab77 --- /dev/null +++ b/spec/support/shared_examples/views/nav_sidebar.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +shared_examples 'has nav sidebar' do + it 'has collapsed nav sidebar on mobile' do + render + + expect(rendered).to have_selector('.nav-sidebar.sidebar-collapsed-mobile') + end +end diff --git a/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb index 05c2f61a606..bf63021a7fa 100644 --- a/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb +++ b/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb @@ -26,6 +26,8 @@ describe 'layouts/nav/sidebar/_admin' do it_behaves_like 'page has active tab', 'Overview' end + it_behaves_like 'has nav sidebar' + context 'on projects' do before do allow(controller).to receive(:controller_name).and_return('projects') diff --git a/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb new file mode 100644 index 00000000000..24b66a0e767 --- /dev/null +++ b/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'layouts/nav/sidebar/_group' do + let(:group) { create(:group) } + + before do + assign(:group, group) + end + + it_behaves_like 'has nav sidebar' +end diff --git a/spec/views/layouts/nav/sidebar/_instance_statistics.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_instance_statistics.html.haml_spec.rb new file mode 100644 index 00000000000..7f7f5637035 --- /dev/null +++ b/spec/views/layouts/nav/sidebar/_instance_statistics.html.haml_spec.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'layouts/nav/sidebar/_instance_statistics' do + it_behaves_like 'has nav sidebar' +end diff --git a/spec/views/layouts/nav/sidebar/_profile.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_profile.html.haml_spec.rb new file mode 100644 index 00000000000..6b820ab0b4c --- /dev/null +++ b/spec/views/layouts/nav/sidebar/_profile.html.haml_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'layouts/nav/sidebar/_profile' do + let(:user) { create(:user) } + + before do + allow(view).to receive(:current_user).and_return(user) + end + + it_behaves_like 'has nav sidebar' +end diff --git a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb index d9f05e5f94f..2c60ccfb754 100644 --- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb +++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb @@ -11,6 +11,8 @@ describe 'layouts/nav/sidebar/_project' do allow(view).to receive(:can?).and_return(true) end + it_behaves_like 'has nav sidebar' + describe 'issue boards' do it 'has board tab' do render |