generated from DFE-Digital/govuk-rails-boilerplate
-
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.
[CPDNPQ-2435] Add "in review" applications screen (#2142)
* [CPDNPQ-2435] Add "in review" applications screen * [CPDNPQ-2435] Add missing review employment_type * [CPDNPQ-2435] Add seeds for applications in review
- Loading branch information
Showing
9 changed files
with
326 additions
and
16 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
54 changes: 54 additions & 0 deletions
54
app/controllers/npq_separation/admin/applications/reviews_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,54 @@ | ||
# frozen_string_literal: true | ||
|
||
module NpqSeparation | ||
module Admin | ||
module Applications | ||
class ReviewsController < NpqSeparation::AdminController | ||
helper_method :employment_types | ||
|
||
def index | ||
applications = Application.includes(:private_childcare_provider, :school, :user) | ||
.merge(review_scope) | ||
.merge(filter_scope) | ||
.merge(search_scope) | ||
|
||
@pagy, @applications = pagy(applications, limit: 9) | ||
end | ||
|
||
private | ||
|
||
def employment_types | ||
%w[ | ||
hospital_school | ||
lead_mentor_for_accredited_itt_provider | ||
local_authority_supply_teacher | ||
local_authority_virtual_school | ||
young_offender_institution | ||
other | ||
] | ||
end | ||
|
||
def filter_params | ||
params.permit %i[ | ||
employment_type | ||
referred_by_return_to_teaching_adviser | ||
cohort_id | ||
] | ||
end | ||
|
||
def review_scope | ||
Application.where(employment_type: employment_types) | ||
.or(Application.where(referred_by_return_to_teaching_adviser: "yes")) | ||
end | ||
|
||
def filter_scope | ||
Application.where(filter_params.compact_blank) | ||
end | ||
|
||
def search_scope | ||
AdminService::ApplicationsSearch.new(q: params[:q]).call | ||
end | ||
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
79 changes: 79 additions & 0 deletions
79
app/views/npq_separation/admin/applications/reviews/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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<h1 class="govuk-heading-l">Registrations in review</h1> | ||
|
||
<div class="admin-search-box"> | ||
<h2 class="govuk-heading-m">Search for registrations in review</h2> | ||
|
||
<%= form_with method: :get do |f| %> | ||
<%= f.govuk_text_field( | ||
:q, | ||
value: params[:q], | ||
label: { text: "Enter the participant ID, name, email address, employer name, or application ID", size: "s" }, | ||
) | ||
%> | ||
|
||
<%= | ||
f.govuk_select( | ||
:employment_type, | ||
options_for_select(employment_types.map { [_1.humanize, _1] }.prepend(nil), params[:employment_type]), | ||
label: { text: "Employment type", size: "s" } | ||
) | ||
%> | ||
|
||
<%= | ||
f.govuk_select( | ||
:referred_by_return_to_teaching_adviser, | ||
options_for_select([ | ||
['', nil], | ||
['Yes', 'yes'], | ||
['No', 'no'], | ||
], params[:referred_by_return_to_teaching_adviser]), | ||
label: { text: "Referred by return to teaching adviser", size: "s" }, | ||
) | ||
%> | ||
|
||
<%= | ||
f.govuk_collection_select( | ||
:cohort_id, | ||
Cohort.all, | ||
:id, | ||
-> { format_cohort _1 }, | ||
options: { selected: params[:cohort_id], include_blank: true }, | ||
label: { text: "Cohort", size: "s" } | ||
) | ||
%> | ||
|
||
<%= f.govuk_submit "Search" %> | ||
<% end %> | ||
</div> | ||
|
||
<%= | ||
govuk_table do |table| | ||
table.with_head do |header| | ||
header.with_row do |row| | ||
row.with_cell(text: "Participant") | ||
row.with_cell(text: "Eligible for funding") | ||
row.with_cell(text: "Provider approval status") | ||
row.with_cell(text: "Notes", classes: 'govuk-!-width-one-third') | ||
row.with_cell(text: "Registration submitted date") | ||
end | ||
end | ||
|
||
table.with_body do |body| | ||
@applications.each do |application| | ||
body.with_row do |row| | ||
row.with_cell do | ||
concat govuk_link_to(application.user.full_name, npq_separation_admin_user_path(application.user)) | ||
concat tag.p(application.employment_type.try(:humanize), class: 'govuk-body-s govuk-!-margin-top-1 govuk-!-margin-bottom-1') | ||
concat tag.p(application.employer_name_to_display, class: 'govuk-body-s govuk-!-margin-top-1 govuk-!-margin-bottom-1') | ||
end | ||
row.with_cell(text: boolean_red_green_tag(application.eligible_for_funding)) | ||
row.with_cell(text: application.lead_provider_approval_status.humanize) | ||
row.with_cell(text: application.notes) | ||
row.with_cell(text: application.created_at.to_formatted_s(:govuk_short)) | ||
end | ||
end | ||
end | ||
end | ||
%> | ||
|
||
<%= govuk_pagination(pagy: @pagy) %> |
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
131 changes: 131 additions & 0 deletions
131
spec/features/npq_separation/admin/applications_in_review_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,131 @@ | ||
require "rails_helper" | ||
|
||
RSpec.feature "Applications in review", type: :feature do | ||
include Helpers::AdminLogin | ||
|
||
let(:cohort_21) { create(:cohort, start_year: 2021) } | ||
let(:cohort_22) { create(:cohort, start_year: 2022) } | ||
|
||
let!(:normal_application) { create(:application) } | ||
let!(:application_for_hospital_school) { create(:application, employment_type: "hospital_school", employer_name: Faker::Company.name, cohort: cohort_21, referred_by_return_to_teaching_adviser: "yes") } | ||
let!(:application_for_la_supply_teacher) { create(:application, employment_type: "local_authority_supply_teacher", cohort: cohort_22, referred_by_return_to_teaching_adviser: "no") } | ||
let!(:application_for_la_virtual_school) { create(:application, employment_type: "local_authority_virtual_school") } | ||
let!(:application_for_lead_mentor) { create(:application, employment_type: "local_authority_virtual_school") } | ||
let!(:application_for_young_offender_institution) { create(:application, employment_type: "young_offender_institution") } | ||
let!(:application_for_other) { create(:application, employment_type: "other") } | ||
let!(:application_for_rtta_yes) { create(:application, referred_by_return_to_teaching_adviser: "yes") } | ||
let!(:application_for_rtta_no) { create(:application, referred_by_return_to_teaching_adviser: "no") } | ||
|
||
before do | ||
sign_in_as create(:admin) | ||
visit npq_separation_admin_applications_path | ||
click_on "In review" | ||
end | ||
|
||
scenario "listing" do | ||
rows = [ | ||
application_for_hospital_school, | ||
application_for_la_supply_teacher, | ||
application_for_la_virtual_school, | ||
application_for_lead_mentor, | ||
application_for_young_offender_institution, | ||
application_for_other, | ||
application_for_rtta_yes, | ||
].map do |application| | ||
[ | ||
[application.user.full_name, application.employment_type.try(:humanize), application.employer_name].compact.join, | ||
application.eligible_for_funding ? "Yes" : "No", | ||
application.lead_provider_approval_status.humanize, | ||
application.notes.to_s, | ||
application.created_at.to_fs(:govuk_short), | ||
] | ||
end | ||
|
||
expect(page).to have_table(rows:) | ||
expect(page).not_to have_text normal_application.user.full_name | ||
expect(page).not_to have_text application_for_rtta_no.user.full_name | ||
end | ||
|
||
scenario "searching with participant ID" do | ||
fill_in("Enter the participant ID", with: application_for_hospital_school.user.ecf_id) | ||
click_on "Search" | ||
|
||
expect(page).to have_text(application_for_hospital_school.user.full_name) | ||
expect(page).not_to have_text(application_for_la_supply_teacher.user.full_name) | ||
end | ||
|
||
scenario "searching with participant name" do | ||
fill_in("Enter the participant ID", with: application_for_hospital_school.user.full_name) | ||
click_on "Search" | ||
|
||
expect(page).to have_text(application_for_hospital_school.user.full_name) | ||
expect(page).not_to have_text(application_for_la_supply_teacher.user.full_name) | ||
end | ||
|
||
scenario "searching with participant email" do | ||
fill_in("Enter the participant ID", with: application_for_hospital_school.user.email) | ||
click_on "Search" | ||
|
||
expect(page).to have_text(application_for_hospital_school.user.full_name) | ||
expect(page).not_to have_text(application_for_la_supply_teacher.user.full_name) | ||
end | ||
|
||
scenario "searching with employer name" do | ||
fill_in("Enter the participant ID", with: application_for_hospital_school.employer_name) | ||
click_on "Search" | ||
|
||
expect(page).to have_text(application_for_hospital_school.user.full_name) | ||
expect(page).not_to have_text(application_for_la_supply_teacher.user.full_name) | ||
end | ||
|
||
scenario "searching with application ID" do | ||
fill_in("Enter the participant ID", with: application_for_hospital_school.ecf_id) | ||
click_on "Search" | ||
|
||
expect(page).to have_text(application_for_hospital_school.user.full_name) | ||
expect(page).not_to have_text(application_for_la_supply_teacher.user.full_name) | ||
end | ||
|
||
scenario "filtering by employment type" do | ||
select "Hospital school", from: "Employment type" | ||
click_on "Search" | ||
|
||
expect(page).to have_text(application_for_hospital_school.user.full_name) | ||
expect(page).not_to have_text(application_for_la_supply_teacher.user.full_name) | ||
end | ||
|
||
scenario "filtering by referred by return to teaching adviser" do | ||
application_for_hospital_school.update!(employer_name: "Return to teaching adviser referral") | ||
|
||
select "Yes", from: "Referred by return to teaching adviser" | ||
click_on "Search" | ||
|
||
expect(page).to have_text(application_for_hospital_school.user.full_name) | ||
expect(page).to have_text(application_for_rtta_yes.user.full_name) | ||
expect(page).not_to have_text(application_for_la_supply_teacher.user.full_name) | ||
expect(page).not_to have_text(application_for_la_virtual_school.user.full_name) | ||
expect(page).not_to have_text(application_for_rtta_no.user.full_name) | ||
end | ||
|
||
scenario "filtering by cohort" do | ||
select "2021/22", from: "Cohort" | ||
click_on "Search" | ||
|
||
expect(page).to have_text(application_for_hospital_school.user.full_name) | ||
expect(page).not_to have_text(application_for_la_supply_teacher.user.full_name) | ||
end | ||
|
||
scenario "combining search and filters" do | ||
fill_in("Enter the participant ID", with: application_for_hospital_school.user.full_name) | ||
select "2021/22", from: "Cohort" | ||
click_on "Search" | ||
|
||
expect(page).to have_text(application_for_hospital_school.user.full_name) | ||
expect(page).not_to have_text(application_for_la_supply_teacher.user.full_name) | ||
|
||
select "2022/23", from: "Cohort" | ||
click_on "Search" | ||
expect(page).not_to have_text(application_for_hospital_school.user.full_name) | ||
expect(page).not_to have_text(application_for_la_supply_teacher.user.full_name) | ||
end | ||
end |
Oops, something went wrong.