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