Skip to content

Commit

Permalink
Add upload consent document page
Browse files Browse the repository at this point in the history
This makes it possible for the applicant to upload their consent
documents.
  • Loading branch information
thomasleese committed Feb 9, 2024
1 parent 1cc0176 commit 36fca4c
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 31 deletions.
58 changes: 29 additions & 29 deletions app/views/teacher_interface/documents/edit_uploads.html.erb
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
<% content_for :page_title, title_with_error_prefix("Check your uploaded files", error: @form.errors.any?) %>
<% content_for :back_link_url, back_history_path(default: teacher_interface_application_form_path) %>

<h1 class="govuk-heading-l">Check your uploaded files – <%= I18n.t("document.document_type.#{@document.document_type}") %> document</h1>

<h2 class="govuk-heading-m">Files added</h2>

<%= govuk_summary_list do |summary_list|
@document.uploads.order(:created_at).each_with_index do |upload, index|
summary_list.with_row do |row|
if @document.allow_multiple_uploads?
row.with_key(text: "File #{index + 1}")
end
<%= form_with model: @form, url: [:teacher_interface, :application_form, @document], method: :patch do |f| %>
<%= f.govuk_error_summary %>

row.with_value { upload_link_to(upload) }

if @document.allow_multiple_uploads?
row.with_action(
text: "Delete",
href: delete_teacher_interface_application_form_document_upload_path(@document, upload),
visually_hidden_text: upload.attachment.filename
)
else
row.with_action(
text: "Change",
href: new_teacher_interface_application_form_document_upload_path(@document),
visually_hidden_text: upload.attachment.filename
)
<h1 class="govuk-heading-l">Check your uploaded files – <%= I18n.t("document.document_type.#{@document.document_type}") %> document</h1>

<h2 class="govuk-heading-m">Files added</h2>

<%= govuk_summary_list do |summary_list|
@document.uploads.order(:created_at).each_with_index do |upload, index|
summary_list.with_row do |row|
if @document.allow_multiple_uploads?
row.with_key(text: "File #{index + 1}")
end

row.with_value { upload_link_to(upload) }

if @document.allow_multiple_uploads?
row.with_action(
text: "Delete",
href: delete_teacher_interface_application_form_document_upload_path(@document, upload),
visually_hidden_text: upload.attachment.filename
)
else
row.with_action(
text: "Change",
href: new_teacher_interface_application_form_document_upload_path(@document),
visually_hidden_text: upload.attachment.filename
)
end
end
end
end
end %>

<%= form_with model: @form, url: [:teacher_interface, :application_form, @document], method: :patch do |f| %>
<%= f.govuk_error_summary %>
end %>

<% if @document.allow_multiple_uploads? %>
<%= f.govuk_radio_buttons_fieldset :add_another,
Expand Down
6 changes: 4 additions & 2 deletions app/views/teacher_interface/uploads/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<%= render "upload_timeout_error" if @form.timeout_error %>

<% if @document.uploads.empty? %>
<% if @document.uploads.empty? || [email protected]_multiple_uploads? %>
<% if @document.english_language_proficiency? %>
<h1 class="govuk-heading-l">Upload your English language proficiency test</h1>
<p class="govuk-body">This document must confirm that you have an English language proficiency test from an approved provider at level B2 of the Common European Framework of Reference for Languages (CEFR) scale.</p>
Expand Down Expand Up @@ -69,7 +69,9 @@

<p class="govuk-body"><%= I18n.t("application_form.qualifications.upload.transcript.description") %></p>
<% elsif @document.signed_consent? %>
<h1 class="govuk-heading-l">Upload your signed consent document</h1>
<h1 class="govuk-heading-l">Upload consent document</h1>
<h2 class="govuk-heading-m"><%= qualification_title(@document.documentable.qualification) %></h2>
<p class="govuk-body">Upload the signed document. Do not send it by email.</p>
<% elsif @document.unsigned_consent? %>
<h1 class="govuk-heading-l">Upload your unsigned consent document</h1>
<% elsif @document.written_statement? %>
Expand Down
30 changes: 30 additions & 0 deletions spec/system/teacher_interface/qualification_consent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@

when_i_check_the_downloaded_checkbox
then_i_see_the(:teacher_qualification_requests_page)

when_i_click_the_upload_task
then_i_see_the(:teacher_upload_document_page)

when_i_upload_a_file
then_i_see_the(:teacher_check_document_page)

when_i_dont_need_to_upload_another_file
then_i_see_the(:teacher_qualification_requests_page)
end

def given_there_is_an_application_form
Expand Down Expand Up @@ -91,6 +100,27 @@ def when_i_check_the_downloaded_checkbox
teacher_qualification_request_download_page.continue_button.click
end

def when_i_click_the_upload_task
teacher_qualification_requests_page
.task_list
.sections
.first
.items
.second
.click
end

def when_i_upload_a_file
teacher_upload_document_page.form.original_attachment.attach_file Rails.root.join(
file_fixture("upload.pdf"),
)
teacher_upload_document_page.form.continue_button.click
end

def when_i_dont_need_to_upload_another_file
teacher_check_document_page.form.continue_button.click
end

def teacher
@teacher ||= create(:teacher)
end
Expand Down

0 comments on commit 36fca4c

Please sign in to comment.