From 8da0e2d44a64522efc154225f4401e25f60ed905 Mon Sep 17 00:00:00 2001 From: timpeat Date: Wed, 31 Jan 2024 17:09:18 +0000 Subject: [PATCH] Make sure overall offence class is passed to MAAT --- app/api/datastore/entities/v1/maat/application.rb | 2 +- spec/api/datastore/v1/maat/applications_spec.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/api/datastore/entities/v1/maat/application.rb b/app/api/datastore/entities/v1/maat/application.rb index 607c060c..2734c6c8 100644 --- a/app/api/datastore/entities/v1/maat/application.rb +++ b/app/api/datastore/entities/v1/maat/application.rb @@ -23,7 +23,7 @@ class Application < BaseApplicationEntity private def case_details - submitted_value('case_details').except( + super.except( 'offences', 'codefendants', # TODO: clarify with MAAT if they need the first court hearing details diff --git a/spec/api/datastore/v1/maat/applications_spec.rb b/spec/api/datastore/v1/maat/applications_spec.rb index ded0516e..58870890 100644 --- a/spec/api/datastore/v1/maat/applications_spec.rb +++ b/spec/api/datastore/v1/maat/applications_spec.rb @@ -20,14 +20,14 @@ context 'with a ready for assessment application' do before do + allow(Utils::OffenceClassCalculator).to receive(:new) { + instance_double(Utils::OffenceClassCalculator, + offence_class: calculated_offence_class) + } api_request end - let(:expected_offence_class) do - Utils::OffenceClassCalculator.new( - offences: application.submitted_application['case_details']['offences'] - ).offence_class - end + let(:calculated_offence_class) { Types::OffenceClass.values.sample } # rubocop:disable Layout/LineLength let(:expected_case_details) do @@ -38,7 +38,7 @@ 'appeal_with_changes_details' => application.submitted_application['case_details']['appeal_with_changes_details'], 'hearing_court_name' => application.submitted_application['case_details']['hearing_court_name'], 'hearing_date' => application.submitted_application['case_details']['hearing_date'], - 'offence_class' => expected_offence_class, + 'offence_class' => calculated_offence_class, 'urn' => application.submitted_application['case_details']['urn'], 'date_case_concluded' => application.submitted_application['case_details']['date_case_concluded'], 'has_case_concluded' => application.submitted_application['case_details']['has_case_concluded'],