Commit c6b01f93 authored by Brandon Labuschagne's avatar Brandon Labuschagne

Ensure instance stats links behave correctly

Instance statistics links should only be displayed when the features are
available for a user.

We need to seperate the logic for instance statistics and analytics.
parent 6867b626
- return unless dashboard_nav_link?(:analytics)
- return unless can?(current_user, :read_instance_statistics)
= nav_link(controller: :dev_ops_score) do
= link_to instance_statistics_dev_ops_score_index_path do
.nav-icon-container
......
......@@ -40,6 +40,10 @@ describe 'layouts/nav/sidebar/_analytics' do
end
context 'and user has access to instance statistics features' do
before do
allow(view).to receive(:can?) { true }
end
it 'has `DevOps Score` link' do
render
......@@ -58,9 +62,11 @@ describe 'layouts/nav/sidebar/_analytics' do
end
context 'and user does not have access to instance statistics features' do
it 'no instance statistics links are rendered' do
allow(view).to receive(:dashboard_nav_link?).and_return(false)
before do
allow(view).to receive(:can?) { false }
end
it 'no instance statistics links are rendered' do
render
expect(rendered).not_to have_content('DevOps Score')
......@@ -78,6 +84,10 @@ describe 'layouts/nav/sidebar/_analytics' do
end
context 'and user has access to instance statistics features' do
before do
allow(view).to receive(:can?) { true }
end
it 'has `DevOps Score` link' do
render
......@@ -96,9 +106,11 @@ describe 'layouts/nav/sidebar/_analytics' do
end
context 'and user does not have access to instance statistics features' do
it 'no instance statistics links are rendered' do
allow(view).to receive(:dashboard_nav_link?).and_return(false)
before do
allow(view).to receive(:can?) { false }
end
it 'no instance statistics links are rendered' do
render
expect(rendered).not_to have_content('DevOps Score')
......
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