Commit 6e557832 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'sh-fix-error-500-explore' into 'master'

Fix 500 error accessing restricted visibility levels

Closes #215552

See merge request gitlab-org/gitlab!30313
parents 2d6bb65b 04e5eb3b
...@@ -52,7 +52,7 @@ module ExploreHelper ...@@ -52,7 +52,7 @@ module ExploreHelper
end end
def public_visibility_restricted? def public_visibility_restricted?
Gitlab::CurrentSettings.restricted_visibility_levels.include? Gitlab::VisibilityLevel::PUBLIC Gitlab::CurrentSettings.restricted_visibility_levels&.include? Gitlab::VisibilityLevel::PUBLIC
end end
private private
......
---
title: Fix 500 error on accessing restricted levels
merge_request: 30313
author:
type: fixed
...@@ -17,4 +17,25 @@ describe ExploreHelper do ...@@ -17,4 +17,25 @@ describe ExploreHelper do
expect(helper.explore_nav_links).to contain_exactly(*menu_items) expect(helper.explore_nav_links).to contain_exactly(*menu_items)
end end
end end
describe '#public_visibility_restricted?' do
using RSpec::Parameterized::TableSyntax
where(:visibility_levels, :expected_status) do
nil | nil
[Gitlab::VisibilityLevel::PRIVATE] | false
[Gitlab::VisibilityLevel::PRIVATE, Gitlab::VisibilityLevel::INTERNAL] | false
[Gitlab::VisibilityLevel::PUBLIC] | true
end
with_them do
before do
stub_application_setting(restricted_visibility_levels: visibility_levels)
end
it 'returns the expected status' do
expect(helper.public_visibility_restricted?).to eq(expected_status)
end
end
end
end end
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