Skip to content

Commit

Permalink
Revert "Refactor subject and date information retrieval in Candidates…
Browse files Browse the repository at this point in the history
…::Regist…" (#3173)

This reverts commit d48929a.
  • Loading branch information
ekumachidi authored Apr 26, 2024
1 parent d48929a commit 3d669a5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions db/data/subjects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
- Music
- Physical Education
- Physics
- Physics with maths
- Primary
- Psychology
- Religious Education
- Social Sciences
- Spanish
- Vocational health
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3d669a5

Please sign in to comment.