summaryrefslogtreecommitdiff
path: root/spec/requests/api/projects_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/api/projects_spec.rb')
-rw-r--r--spec/requests/api/projects_spec.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index b5d3dcee804..dd6afa869e0 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -990,7 +990,7 @@ RSpec.describe API::Projects do
expect do
get api('/projects', admin)
- end.not_to exceed_query_limit(control.count)
+ end.not_to exceed_query_limit(control)
end
end
end
@@ -3203,6 +3203,15 @@ RSpec.describe API::Projects do
expect(json_response['visibility']).to eq('private')
end
+ it 'does not update visibility_level if it is restricted' do
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::INTERNAL])
+
+ put api("/projects/#{project3.id}", user), params: { visibility: 'internal' }
+
+ expect(response).to have_gitlab_http_status(:bad_request)
+ expect(json_response['message']['visibility_level']).to include('internal has been restricted by your GitLab administrator')
+ end
+
it 'does not update name to existing name' do
project_param = { name: project3.name }
@@ -3526,6 +3535,19 @@ RSpec.describe API::Projects do
end
end
+ context 'when authenticated as the admin' do
+ let_it_be(:admin) { create(:admin) }
+
+ it 'ignores visibility level restrictions' do
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::INTERNAL])
+
+ put api("/projects/#{project3.id}", admin), params: { visibility: 'internal' }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['visibility']).to eq('internal')
+ end
+ end
+
context 'when updating repository storage' do
let(:unknown_storage) { 'new-storage' }
let(:new_project) { create(:project, :repository, namespace: user.namespace) }