diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-02-02 19:12:55 +0000 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2018-02-14 14:16:31 -0600 |
commit | ede2f4e5c5b62d4e96228097a19a3ef21212be42 (patch) | |
tree | a8a58b55e815ba7c5f37733849bfa995b01149d0 | |
parent | 0898e59cd07797acdfdb6924468a198b6971cfda (diff) | |
download | gitlab-ce-ede2f4e5c5b62d4e96228097a19a3ef21212be42.tar.gz |
Merge branch 'bvl-fix-500-on-fork-without-restricted-visibility-levels' into 'master'
Avoid error when creating forks and restricted levels are defined
Closes #42607
See merge request gitlab-org/gitlab-ce!16881
-rw-r--r-- | changelogs/unreleased/bvl-fix-500-on-fork-without-restricted-visibility-levels.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/visibility_level.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/visibility_level_spec.rb | 9 |
3 files changed, 15 insertions, 1 deletions
diff --git a/changelogs/unreleased/bvl-fix-500-on-fork-without-restricted-visibility-levels.yml b/changelogs/unreleased/bvl-fix-500-on-fork-without-restricted-visibility-levels.yml new file mode 100644 index 00000000000..378f0ef7ce9 --- /dev/null +++ b/changelogs/unreleased/bvl-fix-500-on-fork-without-restricted-visibility-levels.yml @@ -0,0 +1,5 @@ +--- +title: Fix forking projects when no restricted visibility levels are defined applicationwide +merge_request: 16881 +author: +type: fixed diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb index 6ced06a863d..0b757b2a646 100644 --- a/lib/gitlab/visibility_level.rb +++ b/lib/gitlab/visibility_level.rb @@ -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) diff --git a/spec/lib/gitlab/visibility_level_spec.rb b/spec/lib/gitlab/visibility_level_spec.rb index d85dac630b4..2c1146ceff5 100644 --- a/spec/lib/gitlab/visibility_level_spec.rb +++ b/spec/lib/gitlab/visibility_level_spec.rb @@ -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 |