-
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 adds a page that allows applicants to download their consent document before uploading the signed one.
- Loading branch information
1 parent
426c07c
commit a1dbc0d
Showing
17 changed files
with
247 additions
and
54 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
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
19 changes: 19 additions & 0 deletions
19
app/forms/teacher_interface/qualification_request_download_form.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,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module TeacherInterface | ||
class QualificationRequestDownloadForm < BaseForm | ||
attr_accessor :qualification_request | ||
attribute :downloaded, :boolean | ||
|
||
validates :qualification_request, presence: true | ||
validates :downloaded, presence: true | ||
|
||
def update_model | ||
if downloaded | ||
qualification_request.update!( | ||
unsigned_consent_document_downloaded: true, | ||
) | ||
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,50 @@ | ||
# frozen_string_literal: true | ||
|
||
module DocumentHelper | ||
include UploadHelper | ||
|
||
def document_link_to(document, translated: false) | ||
scope = | ||
( | ||
if translated | ||
document.translated_uploads | ||
else | ||
document.original_uploads | ||
end | ||
) | ||
|
||
if document.optional? && !document.available | ||
"<em>The applicant has indicated that they haven't done an induction period " \ | ||
"and don't have this document.</em>".html_safe | ||
else | ||
uploads = | ||
scope.order(:created_at).select { |upload| upload.attachment.present? } | ||
|
||
malware_scan_active = | ||
FeatureFlags::FeatureFlag.active?(:fetch_malware_scan_result) | ||
convert_to_pdf_active = | ||
FeatureFlags::FeatureFlag.active?(:convert_documents_to_pdf) | ||
|
||
[ | ||
uploads | ||
.map { |upload| upload_link_to(upload) } | ||
.join("<br />") | ||
.html_safe, | ||
if malware_scan_active && scope.scan_result_suspect.exists? | ||
"<em>#{scope.count} #{"file upload".pluralize(scope.count)} has been scanned as malware and deleted.</em>" | ||
elsif request.path.starts_with?("/assessor") && convert_to_pdf_active && | ||
!uploads.all?(&:is_pdf?) | ||
helpers.govuk_link_to( | ||
"Download as PDF (opens in a new tab)", | ||
url_helpers.assessor_interface_application_form_document_pdf_path( | ||
document, | ||
translated ? "translated" : "original", | ||
), | ||
target: :_blank, | ||
rel: :noopener, | ||
) | ||
end, | ||
].compact_blank.join("<br /><br />").html_safe | ||
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
23 changes: 23 additions & 0 deletions
23
app/views/teacher_interface/qualification_requests/edit_download.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,23 @@ | ||
<% content_for :page_title, "Download consent document" %> | ||
<% content_for :back_link_url, back_history_path(default: teacher_interface_application_form_qualification_requests_path) %> | ||
|
||
<%= form_with model: @form, url: [:download, :teacher_interface, :application_form, @qualification_request] do |f| %> | ||
<%= f.govuk_error_summary %> | ||
|
||
<h1 class="govuk-heading-l">Download consent document</h1> | ||
|
||
<h2 class="govuk-heading-m"><%= qualification_title(@qualification) %></h2> | ||
|
||
<article class="moj-ticket-panel"> | ||
<section class="moj-ticket-panel__content moj-ticket-panel__content--blue"> | ||
<h2 class="govuk-heading-m govuk-!-margin-bottom-2">Download the consent document</h2> | ||
<p class="govuk-body"><%= document_link_to(@qualification_request.unsigned_consent_document) %></p> | ||
</section> | ||
</article> | ||
|
||
<%= f.govuk_check_boxes_fieldset :downloaded, multiple: false, small: true, legend: nil do %> | ||
<%= f.govuk_check_box :downloaded, true, false, link_errors: true, label: { text: "I have downloaded the consent document." } %> | ||
<% end %> | ||
|
||
<%= render "shared/save_submit_buttons", 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
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
43 changes: 43 additions & 0 deletions
43
spec/forms/teacher_interface/qualification_request_download_form_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,43 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe TeacherInterface::QualificationRequestDownloadForm, | ||
type: :model do | ||
let(:qualification_request) { create(:qualification_request) } | ||
|
||
subject(:form) { described_class.new(qualification_request:, downloaded:) } | ||
|
||
describe "validations" do | ||
let(:downloaded) { "" } | ||
|
||
it { is_expected.to validate_presence_of(:qualification_request) } | ||
it { is_expected.to validate_presence_of(:downloaded) } | ||
end | ||
|
||
describe "#save" do | ||
subject(:save) { form.save(validate: false) } | ||
|
||
context "with a positive response" do | ||
let(:downloaded) { "true" } | ||
|
||
it "sets unsigned_consent_document_downloaded" do | ||
expect { save }.to change( | ||
qualification_request, | ||
:unsigned_consent_document_downloaded, | ||
).to(true) | ||
end | ||
end | ||
|
||
context "with a negative response" do | ||
let(:downloaded) { "false" } | ||
|
||
it "doesn't set unsigned_consent_document_downloaded" do | ||
expect { save }.to_not change( | ||
qualification_request, | ||
:unsigned_consent_document_downloaded, | ||
) | ||
end | ||
end | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
spec/support/autoload/page_objects/teacher_interface/qualification_request_download.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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module PageObjects | ||
module TeacherInterface | ||
class QualificationRequestDownload < SitePrism::Page | ||
set_url "/teacher/application/qualification-requests/{id}/download" | ||
|
||
element :downloaded_checkbox, ".govuk-checkboxes__input", visible: false | ||
|
||
element :continue_button, ".govuk-button:not(.govuk-button--secondary)" | ||
element :save_and_sign_out_button, ".govuk-button.govuk-button--secondary" | ||
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
Oops, something went wrong.