Skip to content

Commit

Permalink
Remove cross cycle code from 2024 to 2025
Browse files Browse the repository at this point in the history
  We added some cycle year checks and tests. This PR cleans up those
  cycle checks from these PRs
  - #4531
  - #4539
  • Loading branch information
inulty-dfe committed Oct 16, 2024
1 parent ba2308b commit 32cd3cd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 30 deletions.
17 changes: 1 addition & 16 deletions app/components/find/courses/training_locations/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,7 @@ def bottom_heading
end

def show_school_placements_link?
# This is necessary for some component previews to load.
# I don't have time to debug component previews right now.
# This code will be removed after the beginning of the 2025 cycle
# anyway
return false if course.provider.recruitment_cycle.blank?

recruitment_cycle_before_2025? || recruitment_cycle_2025_or_greater_and_selectable_schools?
end

def recruitment_cycle_before_2025?
course.provider.recruitment_cycle_year.to_i < 2025
end

def recruitment_cycle_2025_or_greater_and_selectable_schools?
course.provider.recruitment_cycle_year.to_i >= 2025 &&
course.provider.selectable_school?
course.provider.selectable_school?
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def show_training_locations_school_placements_link_disabled
sites: [Site.new, Site.new],
funding: 'salary',
study_sites: [Site.new, Site.new],
provider: Provider.new(provider_code: 'DFE', selectable_school: false, recruitment_cycle: FactoryBot.build(:recruitment_cycle, year: 2025))).decorate
provider: Provider.new(provider_code: 'DFE', selectable_school: false, recruitment_cycle: FactoryBot.build(:recruitment_cycle))).decorate
render Find::Courses::TrainingLocations::View.new(course:)
end

Expand All @@ -88,7 +88,7 @@ def show_training_locations_school_placements_link_enabled
sites: [Site.new, Site.new],
funding: 'salary',
study_sites: [Site.new, Site.new],
provider: Provider.new(provider_code: 'DFE', selectable_school: true, recruitment_cycle: FactoryBot.build(:recruitment_cycle, year: 2025))).decorate
provider: Provider.new(provider_code: 'DFE', selectable_school: true, recruitment_cycle: FactoryBot.build(:recruitment_cycle))).decorate
render Find::Courses::TrainingLocations::View.new(course:)
end
end
Expand Down
10 changes: 4 additions & 6 deletions spec/features/find/search/viewing_a_course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,19 @@
end
end

scenario 'user sees no school placements in 2025' do
scenario 'user sees no school placements' do
create(:recruitment_cycle, :next)
Timecop.travel(1.month.since(Find::CycleTimetable.find_opens(2025))) do
allow(Settings).to receive(:current_recruitment_cycle_year).and_return(2025)
Timecop.travel(Find::CycleTimetable.find_opens) do
given_there_is_a_findable_course
and_the_provider_does_not_have_selectable_schools
when_i_visit_the_course_page
then_i_see_no_school_placements_link
end
end

scenario 'user views selectable school placements' do
scenario 'user sees selectable school placements' do
create(:recruitment_cycle, :next)
Timecop.travel(1.month.since(Find::CycleTimetable.find_opens(2025))) do
allow(Settings).to receive(:current_recruitment_cycle_year).and_return(2025)
Timecop.travel(Find::CycleTimetable.find_opens) do
given_there_is_a_findable_course
and_the_provider_has_selectable_schools
when_i_visit_the_course_page
Expand Down
10 changes: 4 additions & 6 deletions spec/features/publish/viewing_a_course_preview_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,18 @@
end
end

scenario 'user sees no school placements in 2025' do
scenario 'user sees no school placements' do
create(:recruitment_cycle, :next)
Timecop.travel(1.month.since(Find::CycleTimetable.find_opens(2025))) do
allow(Settings).to receive(:current_recruitment_cycle_year).and_return(2025)
Timecop.travel(Find::CycleTimetable.find_opens) do
given_i_am_authenticated(user: user_with_fee_based_course)
provider.update(selectable_school: false)
when_i_visit_the_publish_course_preview_page
then_i_see_no_school_placements_link
end
end

scenario 'user views school placements' do
Timecop.travel(1.month.since(Find::CycleTimetable.find_opens(2025))) do
allow(Settings).to receive(:current_recruitment_cycle_year).and_return(2025)
scenario 'user sees school placements' do
Timecop.travel(Find::CycleTimetable.find_opens) do
given_i_am_authenticated(user: user_with_fee_based_course)
when_i_visit_the_publish_course_preview_page
and_i_click_link_or_button('View list of school placements')
Expand Down

0 comments on commit 32cd3cd

Please sign in to comment.