debian-mirror-gitlab/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb

128 lines
3.4 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.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 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
2020-11-24 15:15:51 +05:30
context 'on analytics' do
before do
allow(controller).to receive(:controller_name).and_return('dev_ops_report')
end
it_behaves_like 'page has active tab', 'Analytics'
end
2017-08-17 22:00:37 +05:30
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
2020-04-22 19:07:51 +05:30
context 'on settings' do
2021-01-03 14:25:43 +05:30
let(:gitlab_com?) { false }
2020-04-22 19:07:51 +05:30
before do
2021-01-03 14:25:43 +05:30
allow(::Gitlab).to receive(:com?) { gitlab_com? }
2020-04-22 19:07:51 +05:30
render
end
it 'includes General link' do
expect(rendered).to have_link('General', href: general_admin_application_settings_path)
end
2021-01-03 14:25:43 +05:30
context 'when GitLab.com' do
let(:gitlab_com?) { true }
it 'does not include Integrations link' do
expect(rendered).not_to have_link('Integrations', href: integrations_admin_application_settings_path)
end
end
context 'when not GitLab.com' do
it 'includes Integrations link' do
expect(rendered).to have_link('Integrations', href: integrations_admin_application_settings_path)
end
end
2020-04-22 19:07:51 +05:30
context 'when GitLab FOSS' do
it 'does not include Templates link' do
expect(rendered).not_to have_link('Templates', href: '/admin/application_settings/templates')
end
end
end
2017-08-17 22:00:37 +05:30
end