diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
commit | ee664acb356f8123f4f6b00b73c1e1cf0866c7fb (patch) | |
tree | f8479f94a28f66654c6a4f6fb99bad6b4e86a40e /spec/migrations/populate_releases_access_level_from_repository_spec.rb | |
parent | 62f7d5c5b69180e82ae8196b7b429eeffc8e7b4f (diff) |
Add latest changes from gitlab-org/gitlab@15-5-stable-eev15.5.0-rc42
Diffstat (limited to 'spec/migrations/populate_releases_access_level_from_repository_spec.rb')
-rw-r--r-- | spec/migrations/populate_releases_access_level_from_repository_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/migrations/populate_releases_access_level_from_repository_spec.rb b/spec/migrations/populate_releases_access_level_from_repository_spec.rb new file mode 100644 index 00000000000..2bb97662923 --- /dev/null +++ b/spec/migrations/populate_releases_access_level_from_repository_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'spec_helper' + +require_migration! + +RSpec.describe PopulateReleasesAccessLevelFromRepository, :migration do + let(:projects) { table(:projects) } + let(:groups) { table(:namespaces) } + let(:project_features) { table(:project_features) } + + let(:group) { groups.create!(name: 'test-group', path: 'test-group') } + let(:project) { projects.create!(namespace_id: group.id, project_namespace_id: group.id) } + let(:project_feature) do + project_features.create!(project_id: project.id, pages_access_level: 20, **project_feature_attributes) + end + + # repository_access_level and releases_access_level default to ENABLED + describe '#up' do + context 'when releases_access_level is greater than repository_access_level' do + let(:project_feature_attributes) { { repository_access_level: ProjectFeature::PRIVATE } } + + it 'reduces releases_access_level to match repository_access_level' do + expect { migrate! }.to change { project_feature.reload.releases_access_level } + .from(ProjectFeature::ENABLED) + .to(ProjectFeature::PRIVATE) + end + end + + context 'when releases_access_level is less than repository_access_level' do + let(:project_feature_attributes) { { releases_access_level: ProjectFeature::DISABLED } } + + it 'does not change releases_access_level' do + expect { migrate! }.not_to change { project_feature.reload.releases_access_level } + .from(ProjectFeature::DISABLED) + end + end + end +end |