Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update count and restrictions #857

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/controllers/check_records/bulk_searches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def show

data = @bulk_search_response.body
@total = @bulk_search_response.total
@total_not_found = data['not_found'].count
@total_results = data['results'].count
@results ||= data.fetch("results", []).map do |teacher|
QualificationsApi::Teacher.new(teacher['api_data'])
end
Expand Down
4 changes: 3 additions & 1 deletion app/lib/qualifications_api/teacher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def restriction_status
end

def no_restrictions?
return true if sanctions.blank? || sanctions.all?(&:guilty_but_not_prohibited?)
return true if sanctions.blank? ||
sanctions.all?(&:guilty_but_not_prohibited?) ||
sanctions.map(&:title).join.blank?

false
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/check_records/bulk_searches/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<% content_for :page_title, "Bulk Search Results" %>
<% content_for :breadcrumbs do %>
<%= govuk_breadcrumbs(breadcrumbs: { "Home" => check_records_search_path, "Find multiple records" => new_check_records_bulk_search_path, "Results" => nil }) %>
<%= render ActionAtComponent.new(action: "searched") %>
<% end %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<%= render ActionAtComponent.new(action: "searched") %>
<h1 class="govuk-heading-l"><%= pluralize(@total, 'teacher record') %> found</h1>
<p class="govuk-body govuk-!-margin-bottom-6">
We found <%= pluralize(@total, 'teacher record') %> out of the <%= pluralize(@results.count + @not_found.count, 'entry') %> you uploaded.
We found <%= pluralize(@total, 'teacher record') %> out of the <%= pluralize(@total_results + @total_not_found, 'entry') %> you uploaded.
</p>
<%= govuk_tabs do |tabs|
if @results.any?
Expand Down
30 changes: 27 additions & 3 deletions spec/lib/qualifications_api/teacher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
let(:api_data) do
{
"sanctions" => [
{ "guiltyButNotProhibited" => true },
{ "code" => "T6", "start_date" => "2024-01-01" },
{ "possibleMatchOnChildrensBarredList" => true }
]
}
Expand All @@ -434,11 +434,35 @@
it { is_expected.to be_falsey }
end

context "when there are sanctions" do
context "when there are sanctions that are not prohibited" do
let(:api_data) do
{
"sanctions" => [
{ "guiltyButNotProhibited" => true },
{ "code" => "T6", "start_date" => "2024-01-01" },
]
}
end

it { is_expected.to be_truthy }
end

context "when there are sanctions not listed in the Sanction model" do
let(:api_data) do
{
"sanctions" => [
{ "code" => "T7", "start_date" => "2024-01-01" },
]
}
end

it { is_expected.to be_truthy }
end

context "when there are sanctions that are prohibited" do
let(:api_data) do
{
"sanctions" => [
{ "code" => "A13", "start_date" => "2024-01-01" },
]
}
end
Expand Down
Loading