Commit e00003ba authored by Ash McKenzie's avatar Ash McKenzie

Merge branch 'add-view-tests-for-project-sidebar-security-and-compliance' into 'master'

Add view tests for project sidebar - security & compliance

See merge request gitlab-org/gitlab-ee!16357
parents a99b8c20 035cb6d1
......@@ -122,6 +122,82 @@ describe 'layouts/nav/sidebar/_project' do
end
end
describe 'Security and Compliance' do
before do
allow(view).to receive(:can?).with(nil, :read_dependencies, project).and_return(can_read_dependencies)
allow(view).to receive(:can?).with(nil, :read_project_security_dashboard, project).and_return(can_read_dashboard)
render
end
describe 'when the user has full permissions' do
let(:can_read_dashboard) { true }
let(:can_read_dependencies) { true }
it 'top level navigation link is visible' do
expect(rendered).to have_link('Security & Compliance', href: project_security_dashboard_path(project))
end
it 'security dashboard link is visible' do
expect(rendered).to have_link('Security Dashboard', href: project_security_dashboard_path(project))
end
it 'dependency list link is visible' do
expect(rendered).to have_link('Dependency List', href: project_dependencies_path(project))
end
end
describe 'when the user can view only security dashboard' do
let(:can_read_dashboard) { true }
let(:can_read_dependencies) { false }
it 'top level navigation link is visible' do
expect(rendered).to have_link('Security & Compliance', href: project_security_dashboard_path(project))
end
it 'security dashboard link is visible' do
expect(rendered).to have_link('Security Dashboard', href: project_security_dashboard_path(project))
end
it 'dependency list link is not visible' do
expect(rendered).not_to have_link('Dependency List', href: project_dependencies_path(project))
end
end
describe 'when the user can view only dependency list' do
let(:can_read_dashboard) { false }
let(:can_read_dependencies) { true }
it 'top level navigation link is visible' do
expect(rendered).to have_link('Security & Compliance', href: project_dependencies_path(project))
end
it 'security dashboard link is not visible' do
expect(rendered).not_to have_link('Security Dashboard', href: project_security_dashboard_path(project))
end
it 'dependency list link is visible' do
expect(rendered).to have_link('Dependency List', href: project_dependencies_path(project))
end
end
describe 'when the user has no permissions' do
let(:can_read_dependencies) { false }
let(:can_read_dashboard) { false }
it 'top level navigation link is visible' do
expect(rendered).not_to have_link('Security & Compliance', href: project_security_dashboard_path(project))
end
it 'security dashboard link is not visible' do
expect(rendered).not_to have_link('Security Dashboard', href: project_security_dashboard_path(project))
end
it 'dependency list link is not visible' do
expect(rendered).not_to have_link('Dependency List', href: project_dependencies_path(project))
end
end
end
describe 'Packages' do
let(:user) { create(:user) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment