diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/controllers/projects_controller_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) | |
download | gitlab-ce-7e9c479f7de77702622631cff2628a9c8dcbc627.tar.gz |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/controllers/projects_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 0640f9e5724..012a98f433e 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -1437,4 +1437,55 @@ RSpec.describe ProjectsController do def project_moved_message(redirect_route, project) "Project '#{redirect_route.path}' was moved to '#{project.full_path}'. Please update any links and bookmarks that may still have the old path." end + + describe 'GET #unfoldered_environment_names' do + it 'shows the environment names of a public project to an anonymous user' do + create(:environment, project: public_project, name: 'foo') + + get( + :unfoldered_environment_names, + params: { namespace_id: public_project.namespace, id: public_project, format: :json } + ) + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response).to eq(%w[foo]) + end + + it 'does not show environment names of a private project to anonymous users' do + create(:environment, project: project, name: 'foo') + + get( + :unfoldered_environment_names, + params: { namespace_id: project.namespace, id: project, format: :json } + ) + + expect(response).to redirect_to(new_user_session_path) + end + + it 'shows environment names of a private project to a project member' do + create(:environment, project: project, name: 'foo') + project.add_developer(user) + sign_in(user) + + get( + :unfoldered_environment_names, + params: { namespace_id: project.namespace, id: project, format: :json } + ) + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response).to eq(%w[foo]) + end + + it 'does not show environment names of a private project to a logged-in non-member' do + create(:environment, project: project, name: 'foo') + sign_in(user) + + get( + :unfoldered_environment_names, + params: { namespace_id: project.namespace, id: project, format: :json } + ) + + expect(response).to have_gitlab_http_status(:not_found) + end + end end |