-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement status checks for requests
in order to do this it was also necessary to refactor the whole status checks module * Dropped Status::RepositoryPublish model and introduced generic Status::Report model instead * Dropped all routes except Checks#update and Reports#index as discussed with the stakeholders that these are the only requested routes for now. Checks#update will create or update the check. Report#index will list all checks of this report. * Moved common functionality to a concern * Changed routes like requested by stakeholders * Made controllers polymorphic to support requests and repositories for now, more to probably come * Updated controller specs Co-authored-by: Björn Geuken <[email protected]> Co-authored-by: Eduardo Navarro <[email protected]>
- Loading branch information
1 parent
4df2f11
commit 3e22695
Showing
35 changed files
with
604 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module Status | ||
module Concerns | ||
module SetCheckable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
before_action :set_checkable | ||
end | ||
|
||
private | ||
|
||
def set_checkable | ||
set_repository || set_bs_request | ||
return if @checkable | ||
|
||
@error_message = 'Provide at least project_name and repository_name or request number.' unless @error_message | ||
render_error( | ||
status: 404, | ||
errorcode: 'not_found', | ||
message: @error_message | ||
) | ||
end | ||
|
||
def set_project | ||
@project = Project.find_by(name: params[:project_name]) | ||
|
||
return @project if @project | ||
@error_message = "Project '#{params[:project_name]}' not found." | ||
end | ||
|
||
def set_repository | ||
set_project | ||
return unless @project | ||
|
||
@checkable = @project.repositories.find_by(name: params[:repository_name]) | ||
return @checkable if @checkable | ||
|
||
@error_message = "Repository '#{params[:project_name]}/#{params[:repository_name]}' not found." | ||
end | ||
|
||
def set_bs_request | ||
@checkable = BsRequest.with_submit_requests.find_by(number: params[:bs_request_number]) | ||
return @checkable if @checkable | ||
|
||
@error_message = "Submit request with number '#{params[:bs_request_number]}' not found." | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class Status::ReportsController < ApplicationController | ||
include Status::Concerns::SetCheckable | ||
before_action :set_status_report | ||
skip_before_action :require_login, only: [:show] | ||
|
||
# GET /status_reports/published/:project_name/:repository_name/reports/:uuid | ||
def show | ||
@checks = @status_report.checks | ||
@missing_checks = @status_report.missing_checks | ||
end | ||
|
||
private | ||
|
||
def set_status_report | ||
if params[:uuid] | ||
@status_report = @checkable.status_reports.find_by(uuid: params[:uuid]) | ||
return if @status_report | ||
@error_message = "Status report with uuid '#{params[:uuid]} not found.'" | ||
else | ||
@status_report = @checkable.status_reports.first | ||
return if @status_report | ||
@error_message = "Status report not found." | ||
end | ||
render_error( | ||
status: 404, | ||
errorcode: 'not_found', | ||
message: @error_message | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.