From c93fe1d0c51333af84bb3b8eedd0e1ff298f2c4b Mon Sep 17 00:00:00 2001 From: Ekuma Chidi <7931750+ekumachidi@users.noreply.github.com> Date: Fri, 26 Apr 2024 17:28:27 +0100 Subject: [PATCH] =?UTF-8?q?Revert=20"Refactor=20subject=20and=20date=20inf?= =?UTF-8?q?ormation=20retrieval=20in=20Candidates::Regist=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit d48929ad7b91687337ff6b4690b452aca438c339. --- .../subject_and_date_information.rb | 20 +++++-------------- db/data/subjects.yml | 2 ++ .../subject_and_date_information_spec.rb | 7 +++++-- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/app/services/candidates/registrations/subject_and_date_information.rb b/app/services/candidates/registrations/subject_and_date_information.rb index 803911ac69..8968055b11 100644 --- a/app/services/candidates/registrations/subject_and_date_information.rb +++ b/app/services/candidates/registrations/subject_and_date_information.rb @@ -16,11 +16,14 @@ def placement_date end def placement_date_subject - @placement_date_subject ||= find_placement_date_subject + @placement_date_subject ||= Bookings::PlacementDateSubject.find_by( + bookings_placement_date_id: bookings_placement_date_id, + bookings_subject_id: bookings_subject_id + ) end def bookings_subject - @bookings_subject ||= find_bookings_subject + @bookings_subject ||= Bookings::Subject.find_by(id: bookings_subject_id) end def date_and_subject_ids @@ -70,19 +73,6 @@ def secondary_placement_dates_grouped_by_date .flatten .group_by(&:date) end - - private - - def find_placement_date_subject - Bookings::PlacementDateSubject - .joins(:bookings_subject) - .where(bookings_placement_date_id: bookings_placement_date_id, bookings_subjects: { id: bookings_subject_id, hidden: false }) - .first - end - - def find_bookings_subject - Bookings::Subject.find_by(id: bookings_subject_id, hidden: false) - end end end end diff --git a/db/data/subjects.yml b/db/data/subjects.yml index 3bfc7a1fa2..ab6d1ff34e 100644 --- a/db/data/subjects.yml +++ b/db/data/subjects.yml @@ -21,8 +21,10 @@ - Music - Physical Education - Physics +- Physics with maths - Primary - Psychology - Religious Education - Social Sciences - Spanish +- Vocational health diff --git a/spec/services/candidates/registrations/subject_and_date_information_spec.rb b/spec/services/candidates/registrations/subject_and_date_information_spec.rb index d8bc6c2451..e934a9cff1 100644 --- a/spec/services/candidates/registrations/subject_and_date_information_spec.rb +++ b/spec/services/candidates/registrations/subject_and_date_information_spec.rb @@ -105,11 +105,14 @@ subject.bookings_subject_id = 2 end - before { allow(subject).to receive(:find_placement_date_subject).and_return('a') } + before { allow(Bookings::PlacementDateSubject).to receive(:find_by).and_return('a') } specify 'should find the placement date via its id' do subject.placement_date_subject - expect(subject).to have_received(:find_placement_date_subject) + expect(Bookings::PlacementDateSubject).to have_received(:find_by).with( + bookings_placement_date_id: 1, + bookings_subject_id: 2 + ) end end