2020-07-28 23:09:34 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Projects
|
|
|
|
module Pipelines
|
|
|
|
class TestsController < Projects::Pipelines::ApplicationController
|
|
|
|
before_action :authorize_read_build!
|
|
|
|
before_action :builds, only: [:show]
|
|
|
|
|
|
|
|
def summary
|
|
|
|
respond_to do |format|
|
|
|
|
format.json do
|
|
|
|
render json: TestReportSummarySerializer
|
|
|
|
.new(project: project, current_user: @current_user)
|
|
|
|
.represent(pipeline.test_report_summary)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
respond_to do |format|
|
|
|
|
format.json do
|
|
|
|
render json: TestSuiteSerializer
|
|
|
|
.new(project: project, current_user: @current_user)
|
|
|
|
.represent(test_suite, details: true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
|
|
|
def builds
|
2020-10-24 23:57:45 +05:30
|
|
|
@builds ||= pipeline.latest_builds.for_ids(build_ids).presence || render_404
|
2020-07-28 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
def build_ids
|
2020-07-28 23:09:34 +05:30
|
|
|
return [] unless params[:build_ids]
|
|
|
|
|
|
|
|
params[:build_ids].split(",")
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_suite
|
2020-10-24 23:57:45 +05:30
|
|
|
builds.map do |build|
|
|
|
|
build.collect_test_reports!(Gitlab::Ci::Reports::TestReports.new)
|
|
|
|
end.sum
|
2020-07-28 23:09:34 +05:30
|
|
|
end
|
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|