From 1209332a085bc10cc8379d4f9d2c26e782876be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Tue, 4 Dec 2018 15:30:01 +0100 Subject: Replace admin sidebar feature spec with view spec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- spec/features/admin/admin_active_tab_spec.rb | 90 ---------------------- .../layouts/nav/sidebar/_admin.html.haml_spec.rb | 90 ++++++++++++++++++++++ 2 files changed, 90 insertions(+), 90 deletions(-) delete mode 100644 spec/features/admin/admin_active_tab_spec.rb create mode 100644 spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb diff --git a/spec/features/admin/admin_active_tab_spec.rb b/spec/features/admin/admin_active_tab_spec.rb deleted file mode 100644 index 1215908f5ea..00000000000 --- a/spec/features/admin/admin_active_tab_spec.rb +++ /dev/null @@ -1,90 +0,0 @@ -require 'spec_helper' - -RSpec.describe 'admin active tab' do - before do - sign_in(create(:admin)) - end - - shared_examples 'page has active tab' do |title| - it "activates #{title} tab" do - expect(page).to have_selector('.nav-sidebar .sidebar-top-level-items > li.active', count: 1) - expect(page.find('.nav-sidebar .sidebar-top-level-items > li.active')).to have_content(title) - end - end - - shared_examples 'page has active sub tab' do |title| - it "activates #{title} sub tab" do - expect(page).to have_selector('.sidebar-sub-level-items > li.active', count: 2) - expect(page.all('.sidebar-sub-level-items > li.active')[1]).to have_content(title) - end - end - - context 'on home page' do - before do - visit admin_root_path - end - - it_behaves_like 'page has active tab', 'Overview' - end - - context 'on projects' do - before do - visit admin_projects_path - end - - it_behaves_like 'page has active tab', 'Overview' - it_behaves_like 'page has active sub tab', 'Projects' - end - - context 'on groups' do - before do - visit admin_groups_path - end - - it_behaves_like 'page has active tab', 'Overview' - it_behaves_like 'page has active sub tab', 'Groups' - end - - context 'on users' do - before do - visit admin_users_path - end - - it_behaves_like 'page has active tab', 'Overview' - it_behaves_like 'page has active sub tab', 'Users' - end - - context 'on logs' do - before do - visit admin_logs_path - end - - it_behaves_like 'page has active tab', 'Monitoring' - it_behaves_like 'page has active sub tab', 'Logs' - end - - context 'on messages' do - before do - visit admin_broadcast_messages_path - end - - it_behaves_like 'page has active tab', 'Messages' - end - - context 'on hooks' do - before do - visit admin_hooks_path - end - - it_behaves_like 'page has active tab', 'Hooks' - end - - context 'on background jobs' do - before do - visit admin_background_jobs_path - end - - it_behaves_like 'page has active tab', 'Monitoring' - it_behaves_like 'page has active sub tab', 'Background Jobs' - 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 new file mode 100644 index 00000000000..05c2f61a606 --- /dev/null +++ b/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb @@ -0,0 +1,90 @@ +require 'spec_helper' + +describe 'layouts/nav/sidebar/_admin' do + shared_examples 'page has active tab' do |title| + it "activates #{title} tab" do + render + + expect(rendered).to have_selector('.nav-sidebar .sidebar-top-level-items > li.active', count: 1) + expect(rendered).to have_css('.nav-sidebar .sidebar-top-level-items > li.active', text: title) + end + end + + shared_examples 'page has active sub tab' do |title| + it "activates #{title} sub tab" do + render + + expect(rendered).to have_css('.sidebar-sub-level-items > li.active', text: title) + end + end + + context 'on home page' do + before do + allow(controller).to receive(:controller_name).and_return('dashboard') + end + + it_behaves_like 'page has active tab', 'Overview' + end + + context 'on projects' do + before do + allow(controller).to receive(:controller_name).and_return('projects') + allow(controller).to receive(:controller_path).and_return('admin/projects') + end + + it_behaves_like 'page has active tab', 'Overview' + it_behaves_like 'page has active sub tab', 'Projects' + end + + context 'on groups' do + before do + allow(controller).to receive(:controller_name).and_return('groups') + end + + it_behaves_like 'page has active tab', 'Overview' + it_behaves_like 'page has active sub tab', 'Groups' + end + + context 'on users' do + before do + allow(controller).to receive(:controller_name).and_return('users') + end + + it_behaves_like 'page has active tab', 'Overview' + it_behaves_like 'page has active sub tab', 'Users' + end + + context 'on logs' do + before do + allow(controller).to receive(:controller_name).and_return('logs') + end + + it_behaves_like 'page has active tab', 'Monitoring' + it_behaves_like 'page has active sub tab', 'Logs' + end + + context 'on messages' do + before do + allow(controller).to receive(:controller_name).and_return('broadcast_messages') + end + + it_behaves_like 'page has active tab', 'Messages' + end + + context 'on hooks' do + before do + allow(controller).to receive(:controller_name).and_return('hooks') + end + + it_behaves_like 'page has active tab', 'Hooks' + end + + context 'on background jobs' do + before do + allow(controller).to receive(:controller_name).and_return('background_jobs') + end + + it_behaves_like 'page has active tab', 'Monitoring' + it_behaves_like 'page has active sub tab', 'Background Jobs' + end +end -- cgit v1.2.1