-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1743 from DFE-Digital/send-for-review
Send application for review journey
- Loading branch information
Showing
13 changed files
with
211 additions
and
20 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
app/controllers/assessor_interface/assessment_recommendation_review_controller.rb
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 @@ | ||
# frozen_string_literal: true | ||
|
||
module AssessorInterface | ||
class AssessmentRecommendationReviewController < BaseController | ||
before_action :authorize_assessor | ||
before_action :ensure_can_review | ||
before_action :load_assessment_and_application_form | ||
|
||
def edit | ||
@professional_standing_request = | ||
assessment.professional_standing_request if assessment.professional_standing_request.verify_failed? | ||
end | ||
|
||
def update | ||
ActiveRecord::Base.transaction do | ||
assessment.review! | ||
ApplicationFormStatusUpdater.call( | ||
application_form:, | ||
user: current_staff, | ||
) | ||
end | ||
|
||
redirect_to [:status, :assessor_interface, application_form] | ||
end | ||
|
||
private | ||
|
||
def assessment | ||
@assessment ||= | ||
Assessment | ||
.includes(:application_form) | ||
.where(application_form_id: params[:application_form_id]) | ||
.find(params[:assessment_id]) | ||
end | ||
|
||
delegate :application_form, to: :assessment | ||
|
||
def ensure_can_review | ||
unless assessment.can_review? | ||
redirect_to [:assessor_interface, application_form] | ||
end | ||
end | ||
|
||
def load_assessment_and_application_form | ||
@assessment = assessment | ||
@application_form = application_form | ||
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
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
26 changes: 26 additions & 0 deletions
26
app/views/assessor_interface/assessment_recommendation_review/edit.html.erb
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,26 @@ | ||
<% content_for :page_title, "Send application for review" %> | ||
<% content_for :back_link_url, assessor_interface_application_form_path(@application_form) %> | ||
|
||
<h1 class="govuk-heading-xl">Send application for review</h1> | ||
|
||
<p class="govuk-body">The following verification tasks have been flagged for review:</p> | ||
|
||
<%= govuk_table do |table| | ||
if @professional_standing_request.present? | ||
table.with_caption(text: "LoPS") | ||
table.with_head do |head| | ||
head.with_row do |row| | ||
row.with_cell(text: "Internal note") | ||
row.with_cell(text: "Status") | ||
end | ||
end | ||
table.with_body do |body| | ||
body.with_row do |row| | ||
row.with_cell { simple_format @professional_standing_request.verify_note } | ||
row.with_cell { render(StatusTag::Component.new(@professional_standing_request.status)) } | ||
end | ||
end | ||
end | ||
end %> | ||
|
||
<%= govuk_button_to "Continue", [:assessor_interface, @application_form, @assessment, :assessment_recommendation_review], method: :put %> |
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 |
---|---|---|
@@ -1,26 +1,34 @@ | ||
<% content_for :page_title, "#{"Error: " if @form.errors.any?}#{t("helpers.legend.assessor_interface_assessment_recommendation_form.recommendation")}" %> | ||
<% legend = if @assessment.verify? | ||
t(".legend.verify") | ||
elsif @assessment.review? | ||
t(".legend.review") | ||
else | ||
t(".legend.other") | ||
end %> | ||
|
||
<% hint = if @assessment.can_verify? | ||
t(".hint.can_verify") | ||
elsif @assessment.can_review? | ||
t(".hint.can_review") | ||
elsif @assessment.can_award? | ||
t(".hint.can_award") | ||
else | ||
t(".hint.cant_award") | ||
end %> | ||
|
||
<% content_for :page_title, "#{"Error: " if @form.errors.any?}#{legend}" %> | ||
<% content_for :back_link_url, assessor_interface_application_form_path(@application_form) %> | ||
|
||
<%= form_with model: @form, url: [:assessor_interface, @application_form, @assessment], method: :put do |f| %> | ||
<%= f.govuk_error_summary %> | ||
|
||
<% | ||
hint = if @assessment.can_verify? | ||
t(".hint.can_verify") | ||
elsif @assessment.can_award? | ||
t(".hint.can_award") | ||
else | ||
t(".hint.cant_award") | ||
end | ||
%> | ||
|
||
<%= f.govuk_collection_radio_buttons :recommendation, | ||
@assessment.available_recommendations, | ||
:itself, | ||
legend: { size: "xl", tag: "h1" }, | ||
legend: { size: "xl", tag: "h1", text: legend }, | ||
hint: { text: hint } %> | ||
|
||
<%= f.govuk_submit prevent_double_click: false do %> | ||
<%= govuk_link_to "Cancel", assessor_interface_application_form_path(@application_form) %> | ||
<%= govuk_link_to "Cancel", [:assessor_interface, @application_form] %> | ||
<% 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
12 changes: 12 additions & 0 deletions
12
spec/support/autoload/page_objects/assessor_interface/assessment_recommendation_review.rb
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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
module PageObjects | ||
module AssessorInterface | ||
class AssessmentRecommendationReview < SitePrism::Page | ||
set_url "/assessor/applications/{application_form_id}/assessments/{assessment_id}" \ | ||
"/recommendation/review/edit" | ||
|
||
element :continue_button, ".govuk-button" | ||
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
51 changes: 51 additions & 0 deletions
51
spec/system/assessor_interface/reviewing_verifications_spec.rb
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,51 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe "Assessor reviewing verifications", type: :system do | ||
before do | ||
given_the_service_is_open | ||
given_i_am_authorized_as_an_assessor_user | ||
given_there_is_an_application_form_with_failed_verifications | ||
end | ||
|
||
it "sends for review" do | ||
# TODO: review functionality is not built yet, this page can never be reached | ||
when_i_visit_the( | ||
:assessor_assessment_recommendation_review_page, | ||
application_form_id:, | ||
assessment_id:, | ||
) | ||
then_i_see_the( | ||
:assessor_application_page, | ||
application_id: application_form_id, | ||
) | ||
end | ||
|
||
private | ||
|
||
def given_there_is_an_application_form_with_failed_verifications | ||
application_form | ||
end | ||
|
||
def application_form | ||
@application_form ||= | ||
create(:application_form, :submitted).tap do |application_form| | ||
assessment = create(:assessment, :verify, application_form:) | ||
create( | ||
:professional_standing_request, | ||
:received, | ||
assessment:, | ||
verify_passed: false, | ||
) | ||
end | ||
end | ||
|
||
def application_form_id | ||
application_form.id | ||
end | ||
|
||
def assessment_id | ||
application_form.assessment.id | ||
end | ||
end |