diff options
Diffstat (limited to 'spec/models/project_feature_spec.rb')
-rw-r--r-- | spec/models/project_feature_spec.rb | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/spec/models/project_feature_spec.rb b/spec/models/project_feature_spec.rb index fe0b46c3117..87bfdd15773 100644 --- a/spec/models/project_feature_spec.rb +++ b/spec/models/project_feature_spec.rb @@ -288,7 +288,6 @@ RSpec.describe ProjectFeature, feature_category: :projects do end context 'sync packages_enabled' do - # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands where(:initial_value, :new_value, :expected_result) do ProjectFeature::DISABLED | ProjectFeature::DISABLED | false ProjectFeature::DISABLED | ProjectFeature::ENABLED | true @@ -300,7 +299,6 @@ RSpec.describe ProjectFeature, feature_category: :projects do ProjectFeature::PUBLIC | ProjectFeature::ENABLED | true ProjectFeature::PUBLIC | ProjectFeature::PUBLIC | true end - # rubocop:enable Lint/BinaryOperatorWithIdenticalOperands with_them do it 'set correct value' do @@ -314,6 +312,40 @@ RSpec.describe ProjectFeature, feature_category: :projects do end end + describe '#public_packages?' do + let_it_be(:public_project) { create(:project, :public) } + + context 'with packages config enabled' do + context 'when project is private' do + it 'returns false' do + expect(project.project_feature.public_packages?).to eq(false) + end + + context 'with package_registry_access_level set to public' do + before do + project.project_feature.update!(package_registry_access_level: ProjectFeature::PUBLIC) + end + + it 'returns true' do + expect(project.project_feature.public_packages?).to eq(true) + end + end + end + + context 'when project is public' do + it 'returns true' do + expect(public_project.project_feature.public_packages?).to eq(true) + end + end + end + + it 'returns false if packages config is not enabled' do + stub_config(packages: { enabled: false }) + + expect(public_project.project_feature.public_packages?).to eq(false) + end + end + # rubocop:disable Gitlab/FeatureAvailableUsage describe '#feature_available?' do let(:features) { ProjectFeature::FEATURES } |