diff options
Diffstat (limited to 'spec/controllers/projects/deployments_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/deployments_controller_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/controllers/projects/deployments_controller_spec.rb b/spec/controllers/projects/deployments_controller_spec.rb index 85dd86d91e9..c6532e83441 100644 --- a/spec/controllers/projects/deployments_controller_spec.rb +++ b/spec/controllers/projects/deployments_controller_spec.rb @@ -36,6 +36,52 @@ RSpec.describe Projects::DeploymentsController do expect(response).to be_ok expect(response).to match_response_schema('deployments') end + + context 'anonymous user' do + let(:anonymous_user) { create(:user) } + + before do + sign_in(anonymous_user) + end + + context 'project and metrics dashboard are public' do + before do + project.update!( + visibility_level: Gitlab::VisibilityLevel::PUBLIC, + project_feature_attributes: { + metrics_dashboard_access_level: Gitlab::VisibilityLevel::PUBLIC + } + ) + end + + it 'returns a list with deployments information' do + create(:deployment, :success, environment: environment) + + get :index, params: deployment_params + + expect(response).to be_ok + end + end + + context 'project and metrics dashboard are private' do + before do + project.update!( + visibility_level: Gitlab::VisibilityLevel::PRIVATE, + project_feature_attributes: { + metrics_dashboard_access_level: Gitlab::VisibilityLevel::PRIVATE + } + ) + end + + it 'responds with not found' do + create(:deployment, :success, environment: environment) + + get :index, params: deployment_params + + expect(response).to be_not_found + end + end + end end describe 'GET #metrics' do |