From 4692dafbe8eb9a434379ffb47384601603761a12 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Tue, 20 Feb 2024 10:59:44 +0100 Subject: [PATCH] Track history on each controller By including the HistoryTrackable module on the BaseController we end up sharing the origin, check and reset actions across the various controllers that inherit from the BaseController which can lead to bugs if the actions are named the same (for example any `:edit` action was being recorded as a check action because it had been defined once). --- .../assessor_interface/application_forms_controller.rb | 2 ++ .../assessment_recommendation_award_controller.rb | 2 ++ .../assessment_recommendation_decline_controller.rb | 2 ++ .../assessment_recommendation_review_controller.rb | 2 ++ .../assessment_recommendation_verify_controller.rb | 6 ++++-- .../assessor_interface/assessment_sections_controller.rb | 2 ++ .../assessor_interface/assessments_controller.rb | 2 ++ .../assessor_interface/assessor_assignments_controller.rb | 2 ++ app/controllers/assessor_interface/base_controller.rb | 1 - app/controllers/assessor_interface/documents_controller.rb | 1 + .../further_information_requests_controller.rb | 2 ++ app/controllers/assessor_interface/notes_controller.rb | 2 ++ .../professional_standing_requests_controller.rb | 2 ++ .../assessor_interface/qualification_requests_controller.rb | 2 ++ .../assessor_interface/reference_requests_controller.rb | 2 ++ .../assessor_interface/reviewer_assignments_controller.rb | 2 ++ app/controllers/assessor_interface/uploads_controller.rb | 1 + .../assessor_interface/work_histories_controller.rb | 2 ++ 18 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/controllers/assessor_interface/application_forms_controller.rb b/app/controllers/assessor_interface/application_forms_controller.rb index e99d4ba043..93f0c6c601 100644 --- a/app/controllers/assessor_interface/application_forms_controller.rb +++ b/app/controllers/assessor_interface/application_forms_controller.rb @@ -2,6 +2,8 @@ module AssessorInterface class ApplicationFormsController < BaseController + include HistoryTrackable + before_action only: %i[index apply_filters clear_filters] do authorize %i[assessor_interface application_form] end diff --git a/app/controllers/assessor_interface/assessment_recommendation_award_controller.rb b/app/controllers/assessor_interface/assessment_recommendation_award_controller.rb index 71ca29bed2..a02b0f1ac7 100644 --- a/app/controllers/assessor_interface/assessment_recommendation_award_controller.rb +++ b/app/controllers/assessor_interface/assessment_recommendation_award_controller.rb @@ -2,6 +2,8 @@ module AssessorInterface class AssessmentRecommendationAwardController < BaseController + include HistoryTrackable + before_action :ensure_can_award before_action :load_assessment_and_application_form before_action :load_important_notes, only: %i[edit update] diff --git a/app/controllers/assessor_interface/assessment_recommendation_decline_controller.rb b/app/controllers/assessor_interface/assessment_recommendation_decline_controller.rb index 0eb2f28b6c..70d5a761b4 100644 --- a/app/controllers/assessor_interface/assessment_recommendation_decline_controller.rb +++ b/app/controllers/assessor_interface/assessment_recommendation_decline_controller.rb @@ -2,6 +2,8 @@ module AssessorInterface class AssessmentRecommendationDeclineController < BaseController + include HistoryTrackable + before_action :ensure_can_decline before_action :load_assessment_and_application_form diff --git a/app/controllers/assessor_interface/assessment_recommendation_review_controller.rb b/app/controllers/assessor_interface/assessment_recommendation_review_controller.rb index c0829f2383..e73e852ce1 100644 --- a/app/controllers/assessor_interface/assessment_recommendation_review_controller.rb +++ b/app/controllers/assessor_interface/assessment_recommendation_review_controller.rb @@ -2,6 +2,8 @@ module AssessorInterface class AssessmentRecommendationReviewController < BaseController + include HistoryTrackable + before_action :ensure_can_review before_action :load_assessment_and_application_form diff --git a/app/controllers/assessor_interface/assessment_recommendation_verify_controller.rb b/app/controllers/assessor_interface/assessment_recommendation_verify_controller.rb index 8f2503e232..46f445f424 100644 --- a/app/controllers/assessor_interface/assessment_recommendation_verify_controller.rb +++ b/app/controllers/assessor_interface/assessment_recommendation_verify_controller.rb @@ -2,6 +2,8 @@ module AssessorInterface class AssessmentRecommendationVerifyController < BaseController + include HistoryTrackable + before_action :ensure_can_verify before_action :load_assessment_and_application_form @@ -72,8 +74,8 @@ def update_verify_qualifications redirect_to [ :qualification_requests, :assessor_interface, - @application_form, - @assessment, + application_form, + assessment, :assessment_recommendation_verify, ] elsif (check_path = history_stack.last_path_if_check) diff --git a/app/controllers/assessor_interface/assessment_sections_controller.rb b/app/controllers/assessor_interface/assessment_sections_controller.rb index fb0ae89c3f..a929800641 100644 --- a/app/controllers/assessor_interface/assessment_sections_controller.rb +++ b/app/controllers/assessor_interface/assessment_sections_controller.rb @@ -2,6 +2,8 @@ module AssessorInterface class AssessmentSectionsController < BaseController + include HistoryTrackable + before_action { authorize [:assessor_interface, assessment_section] } def show diff --git a/app/controllers/assessor_interface/assessments_controller.rb b/app/controllers/assessor_interface/assessments_controller.rb index 38f66800a6..47d7c88d6b 100644 --- a/app/controllers/assessor_interface/assessments_controller.rb +++ b/app/controllers/assessor_interface/assessments_controller.rb @@ -2,6 +2,8 @@ module AssessorInterface class AssessmentsController < BaseController + include HistoryTrackable + before_action :load_assessment_and_application_form before_action only: %i[edit update] do diff --git a/app/controllers/assessor_interface/assessor_assignments_controller.rb b/app/controllers/assessor_interface/assessor_assignments_controller.rb index 09d6b2e7e8..1e6a3b9dfe 100644 --- a/app/controllers/assessor_interface/assessor_assignments_controller.rb +++ b/app/controllers/assessor_interface/assessor_assignments_controller.rb @@ -2,6 +2,8 @@ module AssessorInterface class AssessorAssignmentsController < BaseController + include HistoryTrackable + before_action { authorize %i[assessor_interface staff_assignment] } def new diff --git a/app/controllers/assessor_interface/base_controller.rb b/app/controllers/assessor_interface/base_controller.rb index 1358258bed..d138d4862c 100644 --- a/app/controllers/assessor_interface/base_controller.rb +++ b/app/controllers/assessor_interface/base_controller.rb @@ -2,7 +2,6 @@ class AssessorInterface::BaseController < ApplicationController include AssessorCurrentNamespace - include HistoryTrackable include StaffAuthenticatable after_action :verify_authorized diff --git a/app/controllers/assessor_interface/documents_controller.rb b/app/controllers/assessor_interface/documents_controller.rb index 023f5f43c7..20fcd3947a 100644 --- a/app/controllers/assessor_interface/documents_controller.rb +++ b/app/controllers/assessor_interface/documents_controller.rb @@ -3,6 +3,7 @@ module AssessorInterface class DocumentsController < BaseController include ActiveStorage::Streaming + include HistoryTrackable include StreamedResponseAuthenticatable include RescueActiveStorageErrors include UploadHelper diff --git a/app/controllers/assessor_interface/further_information_requests_controller.rb b/app/controllers/assessor_interface/further_information_requests_controller.rb index 1a25b56d41..118c59bfb8 100644 --- a/app/controllers/assessor_interface/further_information_requests_controller.rb +++ b/app/controllers/assessor_interface/further_information_requests_controller.rb @@ -2,6 +2,8 @@ module AssessorInterface class FurtherInformationRequestsController < BaseController + include HistoryTrackable + before_action only: %i[preview new create] do authorize %i[assessor_interface further_information_request] end diff --git a/app/controllers/assessor_interface/notes_controller.rb b/app/controllers/assessor_interface/notes_controller.rb index 548b645cc8..a5bda9486f 100644 --- a/app/controllers/assessor_interface/notes_controller.rb +++ b/app/controllers/assessor_interface/notes_controller.rb @@ -2,6 +2,8 @@ module AssessorInterface class NotesController < BaseController + include HistoryTrackable + before_action { authorize %i[assessor_interface note] } def new diff --git a/app/controllers/assessor_interface/professional_standing_requests_controller.rb b/app/controllers/assessor_interface/professional_standing_requests_controller.rb index a1c22cacfc..7d75da76d7 100644 --- a/app/controllers/assessor_interface/professional_standing_requests_controller.rb +++ b/app/controllers/assessor_interface/professional_standing_requests_controller.rb @@ -2,6 +2,8 @@ module AssessorInterface class ProfessionalStandingRequestsController < BaseController + include HistoryTrackable + before_action :set_variables before_action do diff --git a/app/controllers/assessor_interface/qualification_requests_controller.rb b/app/controllers/assessor_interface/qualification_requests_controller.rb index d9776d730f..e1fe3bfb9e 100644 --- a/app/controllers/assessor_interface/qualification_requests_controller.rb +++ b/app/controllers/assessor_interface/qualification_requests_controller.rb @@ -2,6 +2,8 @@ module AssessorInterface class QualificationRequestsController < BaseController + include HistoryTrackable + before_action :set_collection_variables, only: %i[index consent_letter] before_action :set_member_variables, except: %i[index consent_letter] diff --git a/app/controllers/assessor_interface/reference_requests_controller.rb b/app/controllers/assessor_interface/reference_requests_controller.rb index f733d7c778..9f5e5c4c16 100644 --- a/app/controllers/assessor_interface/reference_requests_controller.rb +++ b/app/controllers/assessor_interface/reference_requests_controller.rb @@ -2,6 +2,8 @@ module AssessorInterface class ReferenceRequestsController < BaseController + include HistoryTrackable + before_action :set_individual_variables, except: :index define_history_origin :index diff --git a/app/controllers/assessor_interface/reviewer_assignments_controller.rb b/app/controllers/assessor_interface/reviewer_assignments_controller.rb index c9cb07e748..571370049c 100644 --- a/app/controllers/assessor_interface/reviewer_assignments_controller.rb +++ b/app/controllers/assessor_interface/reviewer_assignments_controller.rb @@ -2,6 +2,8 @@ module AssessorInterface class ReviewerAssignmentsController < BaseController + include HistoryTrackable + before_action { authorize %i[assessor_interface staff_assignment] } def new diff --git a/app/controllers/assessor_interface/uploads_controller.rb b/app/controllers/assessor_interface/uploads_controller.rb index 880b67d522..bab89e1bb0 100644 --- a/app/controllers/assessor_interface/uploads_controller.rb +++ b/app/controllers/assessor_interface/uploads_controller.rb @@ -3,6 +3,7 @@ module AssessorInterface class UploadsController < BaseController include ActiveStorage::Streaming + include HistoryTrackable include StreamedResponseAuthenticatable include RescueActiveStorageErrors include UploadHelper diff --git a/app/controllers/assessor_interface/work_histories_controller.rb b/app/controllers/assessor_interface/work_histories_controller.rb index 07ba88892d..a94d1eeffc 100644 --- a/app/controllers/assessor_interface/work_histories_controller.rb +++ b/app/controllers/assessor_interface/work_histories_controller.rb @@ -2,6 +2,8 @@ module AssessorInterface class WorkHistoriesController < BaseController + include HistoryTrackable + before_action { authorize [:assessor_interface, work_history] } def edit