diff options
Diffstat (limited to 'app/controllers/projects/jobs_controller.rb')
-rw-r--r-- | app/controllers/projects/jobs_controller.rb | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/app/controllers/projects/jobs_controller.rb b/app/controllers/projects/jobs_controller.rb index 802ffd99e41..5a419aab8e1 100644 --- a/app/controllers/projects/jobs_controller.rb +++ b/app/controllers/projects/jobs_controller.rb @@ -6,14 +6,15 @@ class Projects::JobsController < Projects::ApplicationController include ContinueParams include ProjectStatsRefreshConflictsGuard - urgency :low, [:index, :show, :trace, :retry, :play, :cancel, :unschedule, :erase, :raw] + urgency :low, [:index, :show, :trace, :retry, :play, :cancel, :unschedule, :erase, :raw, :test_report_summary] before_action :find_job_as_build, except: [:index, :play, :retry, :show] before_action :find_job_as_processable, only: [:play, :retry, :show] before_action :authorize_read_build_trace!, only: [:trace, :raw] - before_action :authorize_read_build! + before_action :authorize_read_build!, except: [:test_report_summary] + before_action :authorize_read_build_report_results!, only: [:test_report_summary] before_action :authorize_update_build!, - except: [:index, :show, :raw, :trace, :erase, :cancel, :unschedule] + except: [:index, :show, :raw, :trace, :erase, :cancel, :unschedule, :test_report_summary] before_action :authorize_erase_build!, only: [:erase] before_action :authorize_use_build_terminal!, only: [:terminal, :terminal_websocket_authorize] before_action :verify_api_request!, only: :terminal_websocket_authorize @@ -153,6 +154,20 @@ class Projects::JobsController < Projects::ApplicationController end end + def test_report_summary + return not_found unless @build.report_results.present? + + summary = Gitlab::Ci::Reports::TestReportSummary.new(@build.report_results) + + respond_to do |format| + format.json do + render json: TestReportSummarySerializer + .new(project: project, current_user: @current_user) + .represent(summary) + end + end + end + def terminal end @@ -170,6 +185,10 @@ class Projects::JobsController < Projects::ApplicationController attr_reader :build + def authorize_read_build_report_results! + return access_denied! unless can?(current_user, :read_build_report_results, build) + end + def authorize_update_build! return access_denied! unless can?(current_user, :update_build, @build) end |