Commit f0a875f5 authored by Reuben Pereira's avatar Reuben Pereira

Use project_features.container_registry_access_level in specs

Update specs to use project_features.container_registry_access_level
and to test public projects with a private container registry.
parent aeb3fb38
...@@ -26,6 +26,7 @@ RSpec.describe Security::SecurityOrchestrationPolicies::ProjectCreateService do ...@@ -26,6 +26,7 @@ RSpec.describe Security::SecurityOrchestrationPolicies::ProjectCreateService do
expect(policy_project.protected_branches.first.merge_access_levels.map(&:access_level)).to eq([Gitlab::Access::MAINTAINER]) expect(policy_project.protected_branches.first.merge_access_levels.map(&:access_level)).to eq([Gitlab::Access::MAINTAINER])
expect(policy_project.protected_branches.first.push_access_levels.map(&:access_level)).to eq([Gitlab::Access::NO_ACCESS]) expect(policy_project.protected_branches.first.push_access_levels.map(&:access_level)).to eq([Gitlab::Access::NO_ACCESS])
expect(policy_project.team.developers).to contain_exactly(maintainer) expect(policy_project.team.developers).to contain_exactly(maintainer)
expect(policy_project.container_registry_access_level).to eq(ProjectFeature::DISABLED)
end end
end end
......
...@@ -9,12 +9,12 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p ...@@ -9,12 +9,12 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p
let_it_be(:project, reload: true) { create(:project, namespace: user.namespace) } let_it_be(:project, reload: true) { create(:project, namespace: user.namespace) }
let(:container_registry_enabled) { true } let(:container_registry_enabled) { true }
let(:container_registry_enabled_on_project) { true } let(:container_registry_enabled_on_project) { ProjectFeature::ENABLED }
subject { visit project_settings_packages_and_registries_path(project) } subject { visit project_settings_packages_and_registries_path(project) }
before do before do
project.update!(container_registry_enabled: container_registry_enabled_on_project) project.project_feature.update!(container_registry_access_level: container_registry_enabled_on_project)
project.container_expiration_policy.update!(enabled: true) project.container_expiration_policy.update!(enabled: true)
sign_in(user) sign_in(user)
...@@ -104,7 +104,7 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p ...@@ -104,7 +104,7 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p
end end
context 'when container registry is disabled on project' do context 'when container registry is disabled on project' do
let(:container_registry_enabled_on_project) { false } let(:container_registry_enabled_on_project) { ProjectFeature::DISABLED }
it 'does not exists' do it 'does not exists' do
subject subject
......
...@@ -3151,6 +3151,17 @@ RSpec.describe Ci::Build do ...@@ -3151,6 +3151,17 @@ RSpec.describe Ci::Build do
end end
context 'when container registry is enabled' do context 'when container registry is enabled' do
let_it_be_with_reload(:project) { create(:project, :public, :repository, group: group) }
let_it_be_with_reload(:pipeline) do
create(:ci_pipeline, project: project,
sha: project.commit.id,
ref: project.default_branch,
status: 'success')
end
let_it_be_with_refind(:build) { create(:ci_build, pipeline: pipeline) }
let(:container_registry_enabled) { true } let(:container_registry_enabled) { true }
let(:ci_registry) do let(:ci_registry) do
{ key: 'CI_REGISTRY', value: 'registry.example.com', public: true, masked: false } { key: 'CI_REGISTRY', value: 'registry.example.com', public: true, masked: false }
...@@ -3162,7 +3173,7 @@ RSpec.describe Ci::Build do ...@@ -3162,7 +3173,7 @@ RSpec.describe Ci::Build do
context 'and is disabled for project' do context 'and is disabled for project' do
before do before do
project.update!(container_registry_enabled: false) project.project_feature.update_column(:container_registry_access_level, ProjectFeature::DISABLED)
end end
it { is_expected.to include(ci_registry) } it { is_expected.to include(ci_registry) }
...@@ -3171,7 +3182,16 @@ RSpec.describe Ci::Build do ...@@ -3171,7 +3182,16 @@ RSpec.describe Ci::Build do
context 'and is enabled for project' do context 'and is enabled for project' do
before do before do
project.update!(container_registry_enabled: true) project.project_feature.update_column(:container_registry_access_level, ProjectFeature::ENABLED)
end
it { is_expected.to include(ci_registry) }
it { is_expected.to include(ci_registry_image) }
end
context 'and is private for project' do
before do
project.project_feature.update_column(:container_registry_access_level, ProjectFeature::PRIVATE)
end end
it { is_expected.to include(ci_registry) } it { is_expected.to include(ci_registry) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment