Skip to content

Commit

Permalink
Add index view
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasleese committed Feb 19, 2024
1 parent 4b270a8 commit 573dcc0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ class QualificationRequestsController < BaseController
define_history_origin :index

def index
authorize %i[assessor_interface qualification_request]

@qualification_requests = qualification_requests
@application_form = qualification_requests.first.application_form
@assessment = qualification_requests.first.assessment

render layout: "full_from_desktop"
@view_object =
AssessorInterface::QualificationRequestsViewObject.new(
application_form:,
)
end

def consent_letter
Expand Down
46 changes: 29 additions & 17 deletions app/views/assessor_interface/qualification_requests/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
<% content_for :page_title, t("assessor_interface.application_forms.show.assessment_tasks.items.qualification_requests") %>
<% content_for :back_link_url, back_history_path(default: assessor_interface_application_form_path(@application_form)) %>

<%= render "shared/assessor_header", title: t("assessor_interface.application_forms.show.assessment_tasks.items.qualification_requests"), application_form: @application_form %>

<%= render TaskList::Component.new(
[
{
title: "Qualifications",
indentation: false,
items: @qualification_requests.map do |qualification_request|
{
name: qualification_title(qualification_request.qualification),
link: [:edit, :assessor_interface, @application_form, @assessment, qualification_request],
status: qualification_request.status
}
end
}
]
) %>
<h1 class="govuk-heading-xl"><%= t("assessor_interface.application_forms.show.assessment_tasks.items.qualification_requests") %></h1>

<h2 class="govuk-heading-m">All qualifications</h2>

<p class="govuk-body">Complete the following tasks for each qualification:</p>

<%= render TaskList::Component.new([
{
indentation: false,
items: @view_object.all_task_items
}
]) %>

<% if @view_object.show_individual_task_items? %>
<h2 class="govuk-heading-m">Qualification specific</h2>

<p class="govuk-body">As you have to verify more than one qualification you will need to complete specific tasks for each one.</p>

<% @view_object.qualification_requests.map do |qualification_request| %>
<h3 class="govuk-heading-s"><%= qualification_title(qualification_request.qualification) %></h3>

<%= render TaskList::Component.new([
{
indentation: false,
items: @view_object.individual_task_items_for(qualification_request:)
}
]) %>
<% end %>
<% end %>

<%= govuk_button_link_to "Back to overview", [:assessor_interface, @application_form] %>
1 change: 0 additions & 1 deletion spec/factories/assessments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@
after(:create) do |assessment, _evaluator|
create(
:qualification_request,
:requested,
assessment:,
qualification: assessment.application_form.qualifications.first,
)
Expand Down
135 changes: 14 additions & 121 deletions spec/system/assessor_interface/verifying_qualifications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,68 +9,13 @@
given_there_is_an_application_form_with_qualification_request
end

it "received and passed" do
it "check and select consent method" do
when_i_visit_the(:assessor_application_page, reference:)
and_i_see_a_waiting_on_status
and_i_click_the_verify_qualifications_task
then_i_see_the(:assessor_qualification_requests_page, reference:)

when_i_select_the_first_qualification_request
then_i_see_the(:assessor_edit_qualification_request_page, reference:)

when_the_request_is_received_and_passed
then_i_see_the(:assessor_qualification_requests_page, reference:)

when_i_go_back_to_overview
and_i_see_an_in_progress_status
end

it "received and not passed" do
when_i_visit_the(:assessor_application_page, reference:)
and_i_see_a_waiting_on_status
and_i_click_the_verify_qualifications_task
then_i_see_the(:assessor_qualification_requests_page, reference:)

when_i_select_the_first_qualification_request
then_i_see_the(:assessor_edit_qualification_request_page, reference:)

when_the_request_is_received_and_not_passed
then_i_see_the(:assessor_qualification_requests_page, reference:)

when_i_go_back_to_overview
and_i_see_an_in_progress_status
end

it "not received and failed" do
when_i_visit_the(:assessor_application_page, reference:)
and_i_see_a_waiting_on_status
and_i_click_the_verify_qualifications_task
then_i_see_the(:assessor_qualification_requests_page, reference:)

when_i_select_the_first_qualification_request
then_i_see_the(:assessor_edit_qualification_request_page, reference:)

when_the_request_is_not_received_and_failed
then_i_see_the(:assessor_qualification_requests_page, reference:)

when_i_go_back_to_overview
and_i_see_an_in_progress_status
end

it "not received and not failed" do
when_i_visit_the(:assessor_application_page, reference:)
and_i_see_a_waiting_on_status
and_i_click_the_verify_qualifications_task
then_i_see_the(:assessor_qualification_requests_page, reference:)

when_i_select_the_first_qualification_request
then_i_see_the(:assessor_edit_qualification_request_page, reference:)

when_the_request_is_not_received_and_not_failed
then_i_see_the(:assessor_qualification_requests_page, reference:)

when_i_go_back_to_overview
and_i_see_a_waiting_on_status
then_i_see_the(:assessor_application_page, reference:)
end

private
Expand All @@ -79,57 +24,10 @@ def given_there_is_an_application_form_with_qualification_request
application_form
end

def and_i_see_a_waiting_on_status
expect(assessor_application_page.status_summary.value).to have_text(
"WAITING ON QUALIFICATION",
)
end

def and_i_click_the_verify_qualifications_task
assessor_application_page.verify_qualifications_task.link.click
end

def when_i_select_the_first_qualification_request
assessor_qualification_requests_page
.task_list
.qualification_requests
.first
.click
end

def when_the_request_is_received_and_passed
form = assessor_edit_qualification_request_page.form

form.received_true_radio_item.choose
form.passed_true_radio_item.choose
form.submit_button.click
end

def when_the_request_is_received_and_not_passed
form = assessor_edit_qualification_request_page.form

form.received_true_radio_item.choose
form.passed_false_radio_item.choose
form.note_field.fill_in with: "Note."
form.submit_button.click
end

def when_the_request_is_not_received_and_failed
form = assessor_edit_qualification_request_page.form

form.received_false_radio_item.choose
form.failed_true_radio_item.choose
form.submit_button.click
end

def when_the_request_is_not_received_and_not_failed
form = assessor_edit_qualification_request_page.form

form.received_false_radio_item.choose
form.failed_false_radio_item.choose
form.submit_button.click
end

def when_i_go_back_to_overview
assessor_qualification_requests_page.continue_button.click
end
Expand All @@ -140,25 +38,20 @@ def and_i_see_a_received_status
)
end

def and_i_see_an_in_progress_status
expect(assessor_application_page.status_summary.value).to have_text(
"ASSESSMENT IN PROGRESS",
)
end

def application_form
@application_form ||=
begin
application_form =
create(
:application_form,
:submitted,
statuses: %w[waiting_on_qualification],
)
qualification = create(:qualification, :completed, application_form:)
assessment = create(:assessment, :started, application_form:)
create(:qualification_request, :requested, assessment:, qualification:)
application_form
create(
:application_form,
:submitted,
:verification_stage,
:with_teaching_qualification,
).tap do |application_form|
create(
:assessment,
:started,
:with_qualification_request,
application_form:,
)
end
end

Expand Down

0 comments on commit 573dcc0

Please sign in to comment.