diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/models/project_feature_spec.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) | |
download | gitlab-ce-b76ae638462ab0f673e5915986070518dd3f9ad3.tar.gz |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/models/project_feature_spec.rb')
-rw-r--r-- | spec/models/project_feature_spec.rb | 58 |
1 files changed, 45 insertions, 13 deletions
diff --git a/spec/models/project_feature_spec.rb b/spec/models/project_feature_spec.rb index 3fd7e57a5db..5f720f8c4f8 100644 --- a/spec/models/project_feature_spec.rb +++ b/spec/models/project_feature_spec.rb @@ -8,6 +8,8 @@ RSpec.describe ProjectFeature do let(:project) { create(:project) } let(:user) { create(:user) } + it { is_expected.to belong_to(:project) } + describe 'PRIVATE_FEATURES_MIN_ACCESS_LEVEL_FOR_PRIVATE_PROJECT' do it 'has higher level than that of PRIVATE_FEATURES_MIN_ACCESS_LEVEL' do described_class::PRIVATE_FEATURES_MIN_ACCESS_LEVEL_FOR_PRIVATE_PROJECT.each do |feature, level| @@ -189,27 +191,57 @@ RSpec.describe ProjectFeature do end describe 'container_registry_access_level' do - context 'when the project is created with container_registry_enabled false' do - it 'creates project with DISABLED container_registry_access_level' do - project = create(:project, container_registry_enabled: false) + context 'with default value' do + let(:project) { Project.new } + + context 'when the default is false' do + it 'creates project_feature with `disabled` container_registry_access_level' do + stub_config_setting(default_projects_features: { container_registry: false }) - expect(project.project_feature.container_registry_access_level).to eq(described_class::DISABLED) + expect(project.project_feature.container_registry_access_level).to eq(described_class::DISABLED) + end end - end - context 'when the project is created with container_registry_enabled true' do - it 'creates project with ENABLED container_registry_access_level' do - project = create(:project, container_registry_enabled: true) + context 'when the default is true' do + before do + stub_config_setting(default_projects_features: { container_registry: true }) + end - expect(project.project_feature.container_registry_access_level).to eq(described_class::ENABLED) + it 'creates project_feature with `enabled` container_registry_access_level' do + expect(project.project_feature.container_registry_access_level).to eq(described_class::ENABLED) + end + end + + context 'when the default is nil' do + it 'creates project_feature with `disabled` container_registry_access_level' do + stub_config_setting(default_projects_features: { container_registry: nil }) + + expect(project.project_feature.container_registry_access_level).to eq(described_class::DISABLED) + end end end - context 'when the project is created with container_registry_enabled nil' do - it 'creates project with DISABLED container_registry_access_level' do - project = create(:project, container_registry_enabled: nil) + context 'test build factory' do + let(:project) { build(:project, container_registry_access_level: level) } + + subject { project.container_registry_access_level } + + context 'private' do + let(:level) { ProjectFeature::PRIVATE } + + it { is_expected.to eq(level) } + end + + context 'enabled' do + let(:level) { ProjectFeature::ENABLED } + + it { is_expected.to eq(level) } + end + + context 'disabled' do + let(:level) { ProjectFeature::DISABLED } - expect(project.project_feature.container_registry_access_level).to eq(described_class::DISABLED) + it { is_expected.to eq(level) } end end end |