Skip to content

Commit

Permalink
Only highlight known restrictions
Browse files Browse the repository at this point in the history
There are cases where a record will have restrictions that we don't want
to highlight.

We only display the restrictons tag if the code is listed in the
`Sanction::SANCTIONS` constant.
  • Loading branch information
felixclack committed Sep 27, 2024
1 parent ea269ef commit 7a2bde7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
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
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

0 comments on commit 7a2bde7

Please sign in to comment.