diff --git a/app/controllers/projects/deployments_controller.rb b/app/controllers/projects/deployments_controller.rb index a8a6f09d9df..79e59fc1326 100644 --- a/app/controllers/projects/deployments_controller.rb +++ b/app/controllers/projects/deployments_controller.rb @@ -1,14 +1,13 @@ class Projects::DeploymentsController < Projects::ApplicationController + before_action :authorize_read_environment! before_action :authorize_read_deployment! def index - serializer = DeploymentSerializer.new(user: @current_user, project: project) - deployments = environment.deployments.reorder(created_at: :desc) deployments = deployments.where('created_at > ?', params[:after].to_time) if params[:after]&.to_time - deployments = deployments.map { |deployment| serializer.represent(deployment) } - render json: { deployments: deployments } + render json: { deployments: DeploymentSerializer.new(user: @current_user, project: project) + .represent(deployments) } end private