diff --git a/app/models/assessment.rb b/app/models/assessment.rb index 3c6925187f..4402d66bee 100644 --- a/app/models/assessment.rb +++ b/app/models/assessment.rb @@ -93,10 +93,14 @@ def can_award? if skip_verification? all_sections_or_further_information_requests_passed? - else - verify? && enough_reference_requests_review_passed? && + elsif verify? + enough_reference_requests_review_passed? && all_qualification_requests_review_passed? && professional_standing_request_review_passed? + elsif review? + professional_standing_request_review_passed? + else + false end else all_sections_or_further_information_requests_passed? @@ -111,6 +115,8 @@ def can_decline? any_further_information_request_failed? elsif verify? true # TODO: check the state of verification requests + elsif review? + professional_standing_request_review_failed? else false end @@ -232,13 +238,22 @@ def all_qualification_requests_review_passed? end end + def professional_standing_request_review_failed? + if application_form.teaching_authority_provides_written_statement + return true + end + return true if professional_standing_request.nil? + + professional_standing_request.review_failed? + end + def professional_standing_request_review_passed? - if !application_form.teaching_authority_provides_written_statement && - professional_standing_request.present? - professional_standing_request.review_passed? - else - true + if application_form.teaching_authority_provides_written_statement + return true end + return true if professional_standing_request.nil? + + professional_standing_request.review_passed? end def skip_verification?