-
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.
This makes it possible to review for an assessor to review any consent requests.
- Loading branch information
1 parent
ffad9d9
commit e513334
Showing
8 changed files
with
245 additions
and
3 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
app/controllers/assessor_interface/consent_requests_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,67 @@ | ||
# frozen_string_literal: true | ||
|
||
module AssessorInterface | ||
class ConsentRequestsController < BaseController | ||
include HistoryTrackable | ||
|
||
before_action :set_variables | ||
|
||
def edit_review | ||
@form = RequestableReviewForm.new(requestable:) | ||
end | ||
|
||
def update_review | ||
@form = | ||
RequestableReviewForm.new( | ||
requestable:, | ||
user: current_staff, | ||
**review_form_params, | ||
) | ||
|
||
if @form.save | ||
redirect_to [:review, :assessor_interface, application_form, assessment] | ||
else | ||
render :edit_review, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
private | ||
|
||
def application_form | ||
@application_form ||= | ||
ApplicationForm.includes(:assessment).find_by( | ||
reference: params[:application_form_reference], | ||
assessment: { | ||
id: params[:assessment_id], | ||
}, | ||
) | ||
end | ||
|
||
def assessment | ||
@assessment ||= application_form.assessment | ||
end | ||
|
||
def consent_requests | ||
@consent_requests ||= assessment.consent_requests | ||
end | ||
|
||
def consent_request | ||
@consent_request ||= consent_requests.find(params[:id]) | ||
end | ||
|
||
alias_method :requestable, :consent_request | ||
|
||
def set_variables | ||
@consent_request = authorize [:assessor_interface, consent_request] | ||
@application_form = application_form | ||
@assessment = assessment | ||
end | ||
|
||
def review_form_params | ||
params.require(:assessor_interface_requestable_review_form).permit( | ||
:passed, | ||
:note, | ||
) | ||
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,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class AssessorInterface::ConsentRequestPolicy < ApplicationPolicy | ||
def update_review? | ||
user.assess_permission | ||
end | ||
|
||
alias_method :edit_review?, :update_review? | ||
end |
41 changes: 41 additions & 0 deletions
41
app/views/assessor_interface/consent_requests/edit_review.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,41 @@ | ||
<% title = "Review qualification" %> | ||
|
||
<% content_for :page_title, title_with_error_prefix(title, error: @form.errors.any?) %> | ||
<% content_for :back_link_url, back_history_path(default: review_assessor_interface_application_form_assessment_path(@application_form, @assessment)) %> | ||
|
||
<%= form_with model: @form, url: [:review, :assessor_interface, @application_form, @assessment, @consent_request] do |f| %> | ||
<%= f.govuk_error_summary %> | ||
|
||
<h1 class="govuk-heading-xl"><%= title %></h1> | ||
|
||
<h2 class="govuk-heading-m"> | ||
<%= qualification_title(@consent_request.qualification) %> | ||
</h2> | ||
|
||
<% if @consent_request.expired? && @consent_request.received? %> | ||
<%= govuk_inset_text do %> | ||
<p>This qualifications’s status has changed from <%= render(StatusTag::Component.new("overdue")) %> to <%= render(StatusTag::Component.new("received")) %>.</p> | ||
<% end %> | ||
|
||
<%= govuk_details(summary_text: "See previous notes") do %> | ||
<%= govuk_inset_text do %> | ||
<h3 class="govuk-heading-s">Internal note</h3> | ||
<%= simple_format @consent_request.verify_note %> | ||
<% end %> | ||
<% end %> | ||
<% else %> | ||
<%= govuk_inset_text do %> | ||
<h3 class="govuk-heading-s">Internal note</h3> | ||
<%= simple_format @consent_request.verify_note %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= f.govuk_radio_buttons_fieldset :passed, legend: { text: "After review, does the response confirm that this qualification is legitimate?", size: "s" } do %> | ||
<%= f.govuk_radio_button :passed, :true, link_errors: true %> | ||
<%= f.govuk_radio_button :passed, :false do %> | ||
<%= f.govuk_text_area :note, label: { text: "Internal note: briefly explain why the qualification should not be accepted." } %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= render "shared/assessor_interface/continue_cancel_button", f: %> | ||
<% 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
47 changes: 47 additions & 0 deletions
47
spec/policies/assessor_interface/consent_request_policy_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,47 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe AssessorInterface::ConsentRequestPolicy do | ||
it_behaves_like "a policy" | ||
|
||
let(:user) { nil } | ||
let(:record) { nil } | ||
|
||
subject(:policy) { described_class.new(user, record) } | ||
|
||
describe "#index?" do | ||
subject(:index?) { policy.index? } | ||
it_behaves_like "a policy method without permission" | ||
end | ||
|
||
describe "#show?" do | ||
subject(:show?) { policy.show? } | ||
it_behaves_like "a policy method without permission" | ||
end | ||
|
||
describe "#create?" do | ||
subject(:create?) { policy.create? } | ||
it_behaves_like "a policy method without permission" | ||
end | ||
|
||
describe "#new?" do | ||
subject(:new?) { policy.new? } | ||
it_behaves_like "a policy method without permission" | ||
end | ||
|
||
describe "#update_review?" do | ||
subject(:update_review?) { policy.update_review? } | ||
it_behaves_like "a policy method requiring the assess permission" | ||
end | ||
|
||
describe "#edit_review?" do | ||
subject(:edit_review?) { policy.edit_review? } | ||
it_behaves_like "a policy method requiring the assess permission" | ||
end | ||
|
||
describe "#destroy?" do | ||
subject(:destroy?) { policy.destroy? } | ||
it_behaves_like "a policy method without permission" | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
spec/support/autoload/page_objects/assessor_interface/review_consent_request.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,10 @@ | ||
# frozen_string_literal: true | ||
|
||
module PageObjects | ||
module AssessorInterface | ||
class ReviewConsentRequest < ReviewRequestablePage | ||
set_url "/assessor/applications/{reference}/assessments/{assessment_id}" \ | ||
"/consent-requests/{id}/review" | ||
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