Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-11 21:11:57 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-11 21:11:57 +0300
commit603ee53dbdbd3adaced752e1a119eb40d64e9979 (patch)
tree7c3e912fe4c02ea464063a4a224b02bbcdeea580 /spec/controllers
parentc79523e3952dad31a9ab8ccbb9e38466fec3aec3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects_controller_spec.rb81
1 files changed, 66 insertions, 15 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index 34477a7bb68..388d7c2266b 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -878,30 +878,81 @@ RSpec.describe ProjectsController do
end
context 'with project feature attributes' do
- using RSpec::Parameterized::TableSyntax
+ let(:initial_value) { ProjectFeature::PRIVATE }
+ let(:update_to) { ProjectFeature::ENABLED }
- where(:feature, :initial_value, :update_to) do
- :metrics_dashboard_access_level | ProjectFeature::PRIVATE | ProjectFeature::ENABLED
- :container_registry_access_level | ProjectFeature::ENABLED | ProjectFeature::PRIVATE
+ before do
+ project.project_feature.update!(feature_access_level => initial_value)
end
- with_them do
- it "updates the project_feature new" do
- params = {
- namespace_id: project.namespace,
- id: project.path,
- project: {
- project_feature_attributes: {
- "#{feature}": update_to
- }
+ def update_project_feature
+ put :update, params: {
+ namespace_id: project.namespace,
+ id: project.path,
+ project: {
+ project_feature_attributes: {
+ feature_access_level.to_s => update_to
}
}
+ }
+ end
- expect { put :update, params: params }.to change {
- project.reload.project_feature.public_send(feature)
+ shared_examples 'feature update success' do
+ it 'updates access level successfully' do
+ expect { update_project_feature }.to change {
+ project.reload.project_feature.public_send(feature_access_level)
}.from(initial_value).to(update_to)
end
end
+
+ shared_examples 'feature update failure' do
+ it 'cannot update access level' do
+ expect { update_project_feature }.not_to change {
+ project.reload.project_feature.public_send(feature_access_level)
+ }
+ end
+ end
+
+ where(:feature_access_level) do
+ %i[
+ metrics_dashboard_access_level
+ container_registry_access_level
+ environments_access_level
+ feature_flags_access_level
+ ]
+ end
+
+ with_them do
+ it_behaves_like 'feature update success'
+ end
+
+ context 'for feature_access_level operations_access_level' do
+ let(:feature_access_level) { :operations_access_level }
+
+ include_examples 'feature update failure'
+ end
+
+ context 'with feature flag split_operations_visibility_permissions disabled' do
+ before do
+ stub_feature_flags(split_operations_visibility_permissions: false)
+ end
+
+ context 'for feature_access_level operations_access_level' do
+ let(:feature_access_level) { :operations_access_level }
+
+ include_examples 'feature update success'
+ end
+
+ where(:feature_access_level) do
+ %i[
+ environments_access_level feature_flags_access_level
+ ]
+ end
+
+ with_them do
+ it_behaves_like 'feature update failure'
+ end
+ end
end
end