2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
describe 'layouts/nav/sidebar/_admin' do
|
2017-08-17 22:00:37 +05:30
|
|
|
shared_examples 'page has active tab' do |title|
|
|
|
|
it "activates #{title} tab" do
|
2019-02-15 15:39:39 +05:30
|
|
|
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)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples 'page has active sub tab' do |title|
|
|
|
|
it "activates #{title} sub tab" do
|
2019-02-15 15:39:39 +05:30
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_css('.sidebar-sub-level-items > li.active', text: title)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'on home page' do
|
|
|
|
before do
|
2019-02-15 15:39:39 +05:30
|
|
|
allow(controller).to receive(:controller_name).and_return('dashboard')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'page has active tab', 'Overview'
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it_behaves_like 'has nav sidebar'
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
context 'on projects' do
|
|
|
|
before do
|
2019-02-15 15:39:39 +05:30
|
|
|
allow(controller).to receive(:controller_name).and_return('projects')
|
|
|
|
allow(controller).to receive(:controller_path).and_return('admin/projects')
|
2017-08-17 22:00:37 +05:30
|
|
|
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
|
2019-02-15 15:39:39 +05:30
|
|
|
allow(controller).to receive(:controller_name).and_return('groups')
|
2017-08-17 22:00:37 +05:30
|
|
|
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
|
2019-02-15 15:39:39 +05:30
|
|
|
allow(controller).to receive(:controller_name).and_return('users')
|
2017-08-17 22:00:37 +05:30
|
|
|
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
|
2019-02-15 15:39:39 +05:30
|
|
|
allow(controller).to receive(:controller_name).and_return('logs')
|
2017-08-17 22:00:37 +05:30
|
|
|
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
|
2019-02-15 15:39:39 +05:30
|
|
|
allow(controller).to receive(:controller_name).and_return('broadcast_messages')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'page has active tab', 'Messages'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'on hooks' do
|
|
|
|
before do
|
2019-02-15 15:39:39 +05:30
|
|
|
allow(controller).to receive(:controller_name).and_return('hooks')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'page has active tab', 'Hooks'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'on background jobs' do
|
|
|
|
before do
|
2019-02-15 15:39:39 +05:30
|
|
|
allow(controller).to receive(:controller_name).and_return('background_jobs')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'page has active tab', 'Monitoring'
|
|
|
|
it_behaves_like 'page has active sub tab', 'Background Jobs'
|
|
|
|
end
|
|
|
|
end
|