Skip to content
Snippets Groups Projects
Commit 948150f0 authored by Bob Van Landuyt's avatar Bob Van Landuyt
Browse files

Avoid error when no restricted levels are defined

When no visibility levels are defined they could sometimes return
`nil` instead of an empty array. In this case we want to allow all
levels.
parent 8891fbd0
No related branches found
No related tags found
No related merge requests found
---
title: Fix forking projects when no restricted visibility levels are defined applicationwide
merge_request: 16881
author:
type: fixed
Loading
Loading
@@ -60,7 +60,7 @@ module Gitlab
def allowed_levels
restricted_levels = current_application_settings.restricted_visibility_levels
 
self.values - restricted_levels
self.values - Array(restricted_levels)
end
 
def closest_allowed_level(target_level)
Loading
Loading
Loading
Loading
@@ -57,6 +57,15 @@ describe Gitlab::VisibilityLevel do
expect(described_class.allowed_levels)
.to contain_exactly(described_class::PRIVATE, described_class::PUBLIC)
end
it 'returns all levels when no visibility level was set' do
allow(described_class)
.to receive_message_chain('current_application_settings.restricted_visibility_levels')
.and_return(nil)
expect(described_class.allowed_levels)
.to contain_exactly(described_class::PRIVATE, described_class::INTERNAL, described_class::PUBLIC)
end
end
 
describe '.closest_allowed_level' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment