summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-02-02 19:12:55 +0000
committerDouwe Maan <douwe@gitlab.com>2018-02-02 19:12:55 +0000
commitcd5d75c362cdf06efb8174eddfbd0f4b65687dec (patch)
treebff86f0ffdaa6f2dba310a178da04a0433688506
parentb89fd7dd5b7e035e2576c0b18ee2670bf57433c2 (diff)
parent948150f050d14811f6fe1b327387e3c2c1b1fe31 (diff)
downloadgitlab-ce-cd5d75c362cdf06efb8174eddfbd0f4b65687dec.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.yml5
-rw-r--r--lib/gitlab/visibility_level.rb2
-rw-r--r--spec/lib/gitlab/visibility_level_spec.rb9
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 a682de96b3b..2612208a927 100644
--- a/lib/gitlab/visibility_level.rb
+++ b/lib/gitlab/visibility_level.rb
@@ -59,7 +59,7 @@ module Gitlab
def allowed_levels
restricted_levels = Gitlab::CurrentSettings.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