diff --git a/app/lib/qualifications_api/teacher.rb b/app/lib/qualifications_api/teacher.rb index 90b9f09f..1b7df163 100644 --- a/app/lib/qualifications_api/teacher.rb +++ b/app/lib/qualifications_api/teacher.rb @@ -46,7 +46,7 @@ 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 diff --git a/spec/lib/qualifications_api/teacher_spec.rb b/spec/lib/qualifications_api/teacher_spec.rb index 623f8b9d..01f24b65 100644 --- a/spec/lib/qualifications_api/teacher_spec.rb +++ b/spec/lib/qualifications_api/teacher_spec.rb @@ -425,7 +425,7 @@ let(:api_data) do { "sanctions" => [ - { "guiltyButNotProhibited" => true }, + { "code" => "T6", "start_date" => "2024-01-01" }, { "possibleMatchOnChildrensBarredList" => true } ] } @@ -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