Skip to content

Commit 7e1b5f4

Browse files
committed
Merge branch '45779-fix-default-visibility-level-for-projects' into 'master'
Fix default visibility_level for new projects Closes #45779 See merge request gitlab-org/gitlab-ce!24120
2 parents 7a10ef6 + 00a3b46 commit 7e1b5f4

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

app/models/project.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class Project < ActiveRecord::Base
7373
delegate :no_import?, to: :import_state, allow_nil: true
7474

7575
default_value_for :archived, false
76-
default_value_for :visibility_level, gitlab_config_features.visibility_level
76+
default_value_for(:visibility_level) { Gitlab::CurrentSettings.default_project_visibility }
7777
default_value_for :resolve_outdated_diff_discussions, false
7878
default_value_for :container_registry_enabled, gitlab_config_features.container_registry
7979
default_value_for(:repository_storage) { Gitlab::CurrentSettings.pick_repository_storage }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Fix default visibility_level for new projects
3+
merge_request: 24120
4+
author: Fabian Schneider @fabsrc
5+
type: fixed

spec/models/project_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,24 @@
14131413
end
14141414
end
14151415

1416+
describe '#visibility_level' do
1417+
let(:project) { build(:project) }
1418+
1419+
subject { project.visibility_level }
1420+
1421+
context 'by default' do
1422+
it { is_expected.to eq(Gitlab::VisibilityLevel::PRIVATE) }
1423+
end
1424+
1425+
context 'when set to INTERNAL in application settings' do
1426+
before do
1427+
stub_application_setting(default_project_visibility: Gitlab::VisibilityLevel::INTERNAL)
1428+
end
1429+
1430+
it { is_expected.to eq(Gitlab::VisibilityLevel::INTERNAL) }
1431+
end
1432+
end
1433+
14161434
describe '#visibility_level_allowed?' do
14171435
let(:project) { create(:project, :internal) }
14181436

0 commit comments

Comments
 (0)