Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a11f5325
Commit
a11f5325
authored
May 10, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure all Serializers receive `current_user` instead `user`
parent
8e7c073a
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
13 additions
and
13 deletions
+13
-13
app/controllers/projects/builds_controller.rb
app/controllers/projects/builds_controller.rb
+1
-1
app/controllers/projects/deployments_controller.rb
app/controllers/projects/deployments_controller.rb
+1
-1
app/controllers/projects/environments_controller.rb
app/controllers/projects/environments_controller.rb
+3
-3
app/serializers/build_entity.rb
app/serializers/build_entity.rb
+1
-1
app/serializers/environment_entity.rb
app/serializers/environment_entity.rb
+2
-2
spec/serializers/build_entity_spec.rb
spec/serializers/build_entity_spec.rb
+1
-1
spec/serializers/build_serializer_spec.rb
spec/serializers/build_serializer_spec.rb
+1
-1
spec/serializers/deployment_entity_spec.rb
spec/serializers/deployment_entity_spec.rb
+1
-1
spec/serializers/environment_entity_spec.rb
spec/serializers/environment_entity_spec.rb
+1
-1
spec/serializers/environment_serializer_spec.rb
spec/serializers/environment_serializer_spec.rb
+1
-1
No files found.
app/controllers/projects/builds_controller.rb
View file @
a11f5325
...
@@ -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
...
...
app/controllers/projects/deployments_controller.rb
View file @
a11f5325
...
@@ -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
...
...
app/controllers/projects/environments_controller.rb
View file @
a11f5325
...
@@ -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
...
...
app/serializers/build_entity.rb
View file @
a11f5325
...
@@ -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
app/serializers/environment_entity.rb
View file @
a11f5325
...
@@ -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
,
...
...
spec/serializers/build_entity_spec.rb
View file @
a11f5325
...
@@ -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
...
...
spec/serializers/build_serializer_spec.rb
View file @
a11f5325
...
@@ -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
)
}
...
...
spec/serializers/deployment_entity_spec.rb
View file @
a11f5325
...
@@ -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
...
...
spec/serializers/environment_entity_spec.rb
View file @
a11f5325
...
@@ -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
}
...
...
spec/serializers/environment_serializer_spec.rb
View file @
a11f5325
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment