-
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.
Add consent document overview index page
This adds the index page for viewing the qualification requests for a consent document overview.
- Loading branch information
1 parent
502b440
commit 426c07c
Showing
11 changed files
with
252 additions
and
9 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
80 changes: 80 additions & 0 deletions
80
app/view_objects/teacher_interface/qualification_requests_view_object.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,80 @@ | ||
# frozen_string_literal: true | ||
|
||
module TeacherInterface | ||
class QualificationRequestsViewObject | ||
include QualificationHelper | ||
|
||
def initialize(application_form:) | ||
@application_form = application_form | ||
end | ||
|
||
def task_list_sections | ||
qualification_requests.map do |qualification_request| | ||
{ | ||
title: qualification_title(qualification_request.qualification), | ||
items: task_list_items(qualification_request), | ||
} | ||
end | ||
end | ||
|
||
private | ||
|
||
attr_reader :application_form | ||
|
||
def qualification_requests | ||
@qualification_requests ||= | ||
application_form | ||
.assessment | ||
.qualification_requests | ||
.order_by_user | ||
.consent_respondable | ||
end | ||
|
||
def task_list_items(qualification_request) | ||
institution_name = qualification_request.qualification.institution_name | ||
|
||
[ | ||
{ | ||
link: [ | ||
:download, | ||
:teacher_interface, | ||
:application_form, | ||
qualification_request, | ||
], | ||
name: "Download #{institution_name} consent document", | ||
status: | ||
download_unsigned_consent_document_status(qualification_request), | ||
}, | ||
{ | ||
link: [ | ||
:teacher_interface, | ||
:application_form, | ||
qualification_request.signed_consent_document, | ||
], | ||
name: "Upload #{institution_name} consent document", | ||
status: upload_signed_consent_document_status(qualification_request), | ||
}, | ||
] | ||
end | ||
|
||
def download_unsigned_consent_document_status(qualification_request) | ||
if qualification_request.unsigned_consent_document_downloaded | ||
:completed | ||
else | ||
:not_started | ||
end | ||
end | ||
|
||
def upload_signed_consent_document_status(qualification_request) | ||
if qualification_request.unsigned_consent_document_downloaded | ||
if qualification_request.signed_consent_document.completed? | ||
:completed | ||
else | ||
:not_started | ||
end | ||
else | ||
:cannot_start | ||
end | ||
end | ||
end | ||
end |
4 changes: 3 additions & 1 deletion
4
app/views/teacher_interface/qualification_requests/index.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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
<% content_for :page_title, "Consent documents overview" %> | ||
<% content_for :back_link_url, back_history_path(default: teacher_interface_application_form_path) %> | ||
|
||
<h1 class="govuk-heading-l">Consent documents overview</h1> | ||
<h1 class="govuk-heading-xl">Consent documents overview</h1> | ||
|
||
<%= render(TaskList::Component.new(@view_object.task_list_sections)) %> | ||
|
||
<%= govuk_button_link_to t("teacher_interface.application_forms.show.draft.save"), destroy_teacher_session_path, secondary: true %> |
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
143 changes: 143 additions & 0 deletions
143
spec/view_objects/teacher_interface/qualification_requests_view_object_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,143 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe TeacherInterface::QualificationRequestsViewObject do | ||
subject(:view_object) { described_class.new(application_form:) } | ||
|
||
let(:application_form) do | ||
create(:application_form, :verification_stage, :with_assessment) | ||
end | ||
|
||
describe "#task_list_sections" do | ||
subject(:task_list_sections) { view_object.task_list_sections } | ||
|
||
it { is_expected.to be_empty } | ||
|
||
context "with a qualification request" do | ||
let!(:qualification_request) do | ||
create( | ||
:qualification_request, | ||
:consent_requested, | ||
assessment: application_form.assessment, | ||
qualification: | ||
create( | ||
:qualification, | ||
application_form:, | ||
title: "BSc Maths", | ||
institution_name: "University of Maths", | ||
), | ||
) | ||
end | ||
|
||
it do | ||
is_expected.to eq( | ||
[ | ||
{ | ||
title: "BSc Maths (University of Maths)", | ||
items: [ | ||
{ | ||
name: "Download University of Maths consent document", | ||
link: [ | ||
:download, | ||
:teacher_interface, | ||
:application_form, | ||
qualification_request, | ||
], | ||
status: :not_started, | ||
}, | ||
{ | ||
name: "Upload University of Maths consent document", | ||
link: [ | ||
:teacher_interface, | ||
:application_form, | ||
qualification_request.signed_consent_document, | ||
], | ||
status: :cannot_start, | ||
}, | ||
], | ||
}, | ||
], | ||
) | ||
end | ||
|
||
context "when the unsigned consent document is downloaded" do | ||
before do | ||
qualification_request.update!( | ||
unsigned_consent_document_downloaded: true, | ||
) | ||
end | ||
|
||
it do | ||
is_expected.to eq( | ||
[ | ||
{ | ||
title: "BSc Maths (University of Maths)", | ||
items: [ | ||
{ | ||
name: "Download University of Maths consent document", | ||
link: [ | ||
:download, | ||
:teacher_interface, | ||
:application_form, | ||
qualification_request, | ||
], | ||
status: :completed, | ||
}, | ||
{ | ||
name: "Upload University of Maths consent document", | ||
link: [ | ||
:teacher_interface, | ||
:application_form, | ||
qualification_request.signed_consent_document, | ||
], | ||
status: :not_started, | ||
}, | ||
], | ||
}, | ||
], | ||
) | ||
end | ||
|
||
context "when the signed consent document is uploaded" do | ||
before do | ||
qualification_request.signed_consent_document.update!( | ||
completed: true, | ||
) | ||
end | ||
|
||
it do | ||
is_expected.to eq( | ||
[ | ||
{ | ||
title: "BSc Maths (University of Maths)", | ||
items: [ | ||
{ | ||
name: "Download University of Maths consent document", | ||
link: [ | ||
:download, | ||
:teacher_interface, | ||
:application_form, | ||
qualification_request, | ||
], | ||
status: :completed, | ||
}, | ||
{ | ||
name: "Upload University of Maths consent document", | ||
link: [ | ||
:teacher_interface, | ||
:application_form, | ||
qualification_request.signed_consent_document, | ||
], | ||
status: :completed, | ||
}, | ||
], | ||
}, | ||
], | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |