BigW Consortium Gitlab

Commit bd01a5a4 by Grzegorz Bizon Committed by Filipa Lacerda

Add EnvironmentSerializer to EnvironmentsController

parent 14345b21
......@@ -13,7 +13,9 @@ class Projects::EnvironmentsController < Projects::ApplicationController
respond_to do |format|
format.html
format.json do
render json: serialize_as_json(@environments)
render json: EnvironmentSerializer
.new(project: @project)
.represent(@environments)
end
end
end
......@@ -63,19 +65,4 @@ class Projects::EnvironmentsController < Projects::ApplicationController
def environment
@environment ||= project.environments.find(params[:id])
end
def serialize_as_json(resource)
resource.as_json(
include: {
last_deployment: {
include: {
user: { only: [:id, :name, :username], methods: [:avatar_url] },
deployable: { only: [:id, :name, :ref, :tag] }
},
methods: [:short_sha, :commit_title, :commit]
},
project: { methods: [:namespace] }
}
)
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