Commit bc131956 authored by Stan Hu's avatar Stan Hu

Merge branch 'rc/fix_public_dashboard_deployments' into 'master'

Remove read_environment check for deployments

Closes #219146

See merge request gitlab-org/gitlab!35454
parents 0632ad80 9c73ee32
# frozen_string_literal: true # frozen_string_literal: true
class Projects::DeploymentsController < Projects::ApplicationController class Projects::DeploymentsController < Projects::ApplicationController
before_action :authorize_read_environment!
before_action :authorize_read_deployment! before_action :authorize_read_deployment!
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
......
...@@ -36,6 +36,52 @@ RSpec.describe Projects::DeploymentsController do ...@@ -36,6 +36,52 @@ RSpec.describe Projects::DeploymentsController do
expect(response).to be_ok expect(response).to be_ok
expect(response).to match_response_schema('deployments') expect(response).to match_response_schema('deployments')
end 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 end
describe 'GET #metrics' do describe 'GET #metrics' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment