Commit a11f5325 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Ensure all Serializers receive `current_user` instead `user`

parent 8e7c073a
......@@ -82,7 +82,7 @@ class Projects::BuildsController < Projects::ApplicationController
def status
render json: BuildSerializer
.new(project: @project, user: @current_user)
.new(project: @project, current_user: @current_user)
.represent_status(@build)
end
......
......@@ -6,7 +6,7 @@ class Projects::DeploymentsController < Projects::ApplicationController
deployments = environment.deployments.reorder(created_at: :desc)
deployments = deployments.where('created_at > ?', params[:after].to_time) if params[:after]&.to_time
render json: { deployments: DeploymentSerializer.new(user: @current_user, project: project)
render json: { deployments: DeploymentSerializer.new(project: project)
.represent_concise(deployments) }
end
......
......@@ -18,7 +18,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
format.json do
render json: {
environments: EnvironmentSerializer
.new(project: @project, user: @current_user)
.new(project: @project, current_user: @current_user)
.with_pagination(request, response)
.within_folders
.represent(@environments),
......@@ -38,7 +38,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
format.json do
render json: {
environments: EnvironmentSerializer
.new(project: @project, user: @current_user)
.new(project: @project, current_user: @current_user)
.with_pagination(request, response)
.represent(@environments),
available_count: folder_environments.available.count,
......@@ -143,7 +143,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
if rollout_status.nil?
render body: nil, status: 204 # no result yet
else
serializer = RolloutStatusSerializer.new(project: @project, user: @current_user)
serializer = RolloutStatusSerializer.new(project: @project, current_user: @current_user)
render json: serializer.represent(rollout_status)
end
end
......
......@@ -30,6 +30,6 @@ class BuildEntity < Grape::Entity
end
def detailed_status
build.detailed_status(request.user)
build.detailed_status(request.current_user)
end
end
......@@ -31,7 +31,7 @@ class EnvironmentEntity < Grape::Entity
end
expose :terminal_path, if: ->(environment, _) { environment.deployment_service_ready? } do |environment|
can?(request.user, :admin_environment, environment.project) &&
can?(request.current_user, :admin_environment, environment.project) &&
terminal_namespace_project_environment_path(
environment.project.namespace,
environment.project,
......@@ -39,7 +39,7 @@ class EnvironmentEntity < Grape::Entity
end
expose :rollout_status_path, if: ->(environment, _) { environment.deployment_service_ready? } do |environment|
can?(request.user, :read_deploy_board, environment.project) &&
can?(request.current_user, :read_deploy_board, environment.project) &&
status_namespace_project_environment_path(
environment.project.namespace,
environment.project,
......
......@@ -6,7 +6,7 @@ describe BuildEntity do
let(:request) { double('request') }
before do
allow(request).to receive(:user).and_return(user)
allow(request).to receive(:current_user).and_return(user)
end
let(:entity) do
......
......@@ -4,7 +4,7 @@ describe BuildSerializer do
let(:user) { create(:user) }
let(:serializer) do
described_class.new(user: user)
described_class.new(current_user: user)
end
subject { serializer.represent(resource) }
......
......@@ -8,7 +8,7 @@ describe DeploymentEntity do
subject { entity.as_json }
before do
allow(request).to receive(:user).and_return(user)
allow(request).to receive(:current_user).and_return(user)
end
it 'exposes internal deployment id' do
......
......@@ -5,7 +5,7 @@ describe EnvironmentEntity do
let(:environment) { create(:environment) }
let(:entity) do
described_class.new(environment, request: double(user: user))
described_class.new(environment, request: double(current_user: user))
end
subject { entity.as_json }
......
......@@ -6,7 +6,7 @@ describe EnvironmentSerializer do
let(:json) do
described_class
.new(user: user, project: project)
.new(current_user: user, project: project)
.represent(resource)
end
......
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