Skip to content

Commit

Permalink
Fix tests which fail when current cycle closes
Browse files Browse the repository at this point in the history
These tests make more sense to fix when the time comes because:

- The next recruitment cycle will become the current recruitment cycle

- We should be able to remove the TDA feature flag and recruitment cycle check at this point

This branch will act as a SPIKE.
  • Loading branch information
avinhurry committed Jul 17, 2024
1 parent 3ab34f4 commit 13319f0
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 31 deletions.
2 changes: 1 addition & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ cookies:
name: _consented_to_analytics_cookies
expire_after_days: 182

current_recruitment_cycle_year: 2024
current_recruitment_cycle_year: 2025
next_cycle_open_date: 2024-10-1

govuk_notify:
Expand Down
3 changes: 1 addition & 2 deletions spec/controllers/publish/courses/outcome_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
require 'rails_helper'

RSpec.describe Publish::Courses::OutcomeController do
let(:recruitment_cycle) { create(:recruitment_cycle, year: 2025) }
let(:user) { create(:user, providers: [build(:provider, recruitment_cycle:)]) }
let(:user) { create(:user, providers: [build(:provider)]) }
let(:provider) { user.providers.first }

before do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,10 @@
end

def given_i_am_authenticated_as_a_provider_user
recruitment_cycle = create(:recruitment_cycle, year: 2025)
@user = create(:user, providers: [build(:provider, recruitment_cycle:, provider_type: 'lead_school', sites: [build(:site), build(:site)], study_sites: [build(:site, :study_site), build(:site, :study_site)])])
@user = create(:user, providers: [build(:provider, provider_type: 'lead_school', sites: [build(:site), build(:site)], study_sites: [build(:site, :study_site), build(:site, :study_site)])])
@provider = @user.providers.first
create(:provider, :accredited_provider, provider_code: '1BJ')
@accredited_provider = create(:provider, :accredited_provider, provider_code: '1BJ', recruitment_cycle:)
@accredited_provider = create(:provider, :accredited_provider, provider_code: '1BK')
@provider.accrediting_provider_enrichments = []
@provider.accrediting_provider_enrichments << AccreditingProviderEnrichment.new(
{
Expand All @@ -161,7 +160,7 @@ def and_i_have_a_teacher_degree_apprenticeship_course
end

def when_i_visit_the_course_description_tab
publish_provider_courses_show_page.load(provider_code: @provider.provider_code, recruitment_cycle_year: 2025, course_code: @course.course_code)
publish_provider_courses_show_page.load(provider_code: @provider.provider_code, recruitment_cycle_year: @provider.recruitment_cycle_year, course_code: @course.course_code)
end

def then_i_see_a_levels_row
Expand Down
17 changes: 4 additions & 13 deletions spec/features/publish/courses/editing_course_outcome_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

context 'TDA course' do
scenario 'changing the outcome from non TDA to TDA' do
given_i_am_authenticated_as_a_provider_user_in_the_next_cycle
given_i_am_authenticated_as_a_provider_user
and_the_tda_feature_flag_is_active
and_there_is_a_qts_course_i_want_to_edit
when_i_visit_the_course_outcome_page_in_the_next_cycle
Expand All @@ -45,7 +45,7 @@

context 'fee course' do
scenario 'changing the outcome from TDA to non TDA' do
given_i_am_authenticated_as_a_provider_user_in_the_next_cycle
given_i_am_authenticated_as_a_provider_user
and_the_tda_feature_flag_is_active
and_there_is_a_tda_course_i_want_to_edit
when_i_visit_the_course_outcome_page_in_the_next_cycle
Expand All @@ -72,7 +72,7 @@

context 'salaried course' do
scenario 'changing the outcome from TDA to non TDA' do
given_i_am_authenticated_as_a_provider_user_in_the_next_cycle
given_i_am_authenticated_as_a_provider_user
and_the_tda_feature_flag_is_active
and_there_is_a_tda_course_i_want_to_edit
when_i_visit_the_course_outcome_page_in_the_next_cycle
Expand All @@ -88,15 +88,6 @@
end
end

def given_i_am_authenticated_as_a_provider_user_in_the_next_cycle
next_cycle_providers = [build(:provider, :next_recruitment_cycle, :accredited_provider,
courses: [create(:course, :with_accrediting_provider)],
sites: [build(:site), build(:site)],
study_sites: [build(:site, :study_site)])]
@next_cycle_user = create(:user, providers: next_cycle_providers)
given_i_am_authenticated(user: @next_cycle_user)
end

def given_i_am_authenticated_as_a_provider_user
given_i_am_authenticated(user: create(:user, :with_provider))
end
Expand Down Expand Up @@ -148,7 +139,7 @@ def and_the_course_outcome_is_updated
end

def then_i_am_shown_the_correct_qts_options
expect(publish_courses_outcome_edit_page.qualification_names).to contain_exactly('QTS', 'QTS with PGCE', 'PGDE with QTS')
expect(publish_courses_outcome_edit_page.qualification_names).to contain_exactly('QTS', 'QTS with PGCE', 'PGDE with QTS', 'Teacher degree apprenticeship (TDA) with QTS')
end

def then_i_am_shown_the_correct_non_qts_options
Expand Down
7 changes: 3 additions & 4 deletions spec/features/publish/courses/new_tda_course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,10 @@
end

def given_i_am_authenticated_as_a_school_direct_provider_user
recruitment_cycle = create(:recruitment_cycle, year: 2025)
@user = create(:user, providers: [build(:provider, recruitment_cycle:, provider_type: 'lead_school', sites: [build(:site), build(:site)], study_sites: [build(:site, :study_site), build(:site, :study_site)])])
@user = create(:user, providers: [build(:provider, provider_type: 'lead_school', sites: [build(:site), build(:site)], study_sites: [build(:site, :study_site), build(:site, :study_site)])])
@provider = @user.providers.first
create(:provider, :accredited_provider, provider_code: '1BJ')
@accredited_provider = create(:provider, :accredited_provider, provider_code: '1BJ', recruitment_cycle:)
@accredited_provider = create(:provider, :accredited_provider, provider_code: '1BK')
@provider.accrediting_provider_enrichments = []
@provider.accrediting_provider_enrichments << AccreditingProviderEnrichment.new(
{
Expand All @@ -240,7 +239,7 @@ def given_i_am_authenticated_as_a_scitt_provider_user
@user = create(
:user,
providers: [
create(:provider, :scitt, recruitment_cycle: build(:recruitment_cycle, year: 2025), sites: [build(:site), build(:site)], study_sites: [build(:site, :study_site), build(:site, :study_site)])
create(:provider, :scitt, sites: [build(:site), build(:site)], study_sites: [build(:site, :study_site), build(:site, :study_site)])
]
)
given_i_am_authenticated(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@
end

def given_i_am_authenticated_as_a_provider_user
recruitment_cycle = create(:recruitment_cycle, year: 2025)
@user = create(:user, providers: [build(:provider, recruitment_cycle:, provider_type: 'lead_school', sites: [build(:site), build(:site)], study_sites: [build(:site, :study_site), build(:site, :study_site)])])
@user = create(:user, providers: [build(:provider, provider_type: 'lead_school', sites: [build(:site), build(:site)], study_sites: [build(:site, :study_site), build(:site, :study_site)])])
@provider = @user.providers.first
create(:provider, :accredited_provider, provider_code: '1BJ')
@accredited_provider = create(:provider, :accredited_provider, provider_code: '1BJ', recruitment_cycle:)
@accredited_provider = create(:provider, :accredited_provider, provider_code: '1BK')
@provider.accrediting_provider_enrichments = []
@provider.accrediting_provider_enrichments << AccreditingProviderEnrichment.new(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
end

def given_i_am_authenticated_as_a_provider_user
recruitment_cycle = create(:recruitment_cycle, year: 2025)
@user = create(:user, providers: [build(:provider, recruitment_cycle:, provider_type: 'lead_school', sites: [build(:site), build(:site)], study_sites: [build(:site, :study_site), build(:site, :study_site)])])
@user = create(:user, providers: [build(:provider, provider_type: 'lead_school', sites: [build(:site), build(:site)], study_sites: [build(:site, :study_site), build(:site, :study_site)])])
@provider = @user.providers.first
create(:provider, :accredited_provider, provider_code: '1BJ')
@accredited_provider = create(:provider, :accredited_provider, provider_code: '1BJ', recruitment_cycle:)
@accredited_provider = create(:provider, :accredited_provider, provider_code: '1BK')
@provider.accrediting_provider_enrichments = []
@provider.accrediting_provider_enrichments << AccreditingProviderEnrichment.new(
{
Expand Down
2 changes: 1 addition & 1 deletion spec/features/publish/viewing_a_course_preview_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def user_with_fee_based_course
:open,
:secondary,
:fee_type_based,
applications_open_from: Time.zone.tomorrow,
applications_open_from: RecruitmentCycle.current.application_start_date,
accrediting_provider:,
site_statuses:, enrichments: [course_enrichment],
study_sites: [study_site],
Expand Down

0 comments on commit 13319f0

Please sign in to comment.