diff --git a/app/components/candidate_interface/deadline_banner_component.html.erb b/app/components/candidate_interface/deadline_banner_component.html.erb index 957dd0b4745..11518316be2 100644 --- a/app/components/candidate_interface/deadline_banner_component.html.erb +++ b/app/components/candidate_interface/deadline_banner_component.html.erb @@ -1,4 +1,4 @@ <%= govuk_notification_banner(title_text: t('notification_banner.important')) do |notification_banner| %> - <% notification_banner.with_heading(text: "The deadline for applying to courses starting in the #{academic_year} academic year is #{deadline[:time]} on #{deadline[:date]}") %> -

Courses may fill up before then. Check course availability with your provider.

+ <% notification_banner.with_heading(text: t('heading', academic_year:, deadline_time: deadline[:time], deadline_date: deadline[:date])) %> +

<%= t('text') %>

<% end %> diff --git a/app/components/candidate_interface/deadline_banner_component.rb b/app/components/candidate_interface/deadline_banner_component.rb index 15b83f937f2..8207a9f4dac 100644 --- a/app/components/candidate_interface/deadline_banner_component.rb +++ b/app/components/candidate_interface/deadline_banner_component.rb @@ -7,15 +7,14 @@ def initialize(application_form:, flash_empty:) end def render? - flash_empty && render_deadline_banner? + flash_empty && CycleTimetable.show_apply_deadline_banner?(@application_form) end def deadline - if CycleTimetable.show_apply_2_deadline_banner?(@application_form) - apply_2_deadline - else - apply_1_deadline - end + { + date: CycleTimetable.date(:apply_2_deadline).to_fs(:govuk_date), + time: CycleTimetable.date(:apply_2_deadline).to_fs(:govuk_time), + } end def academic_year @@ -24,24 +23,6 @@ def academic_year private - def render_deadline_banner? - CycleTimetable.show_apply_1_deadline_banner?(@application_form) || CycleTimetable.show_apply_2_deadline_banner?(@application_form) - end - - def apply_1_deadline - { - date: CycleTimetable.date(:apply_1_deadline).to_fs(:govuk_date), - time: CycleTimetable.date(:apply_1_deadline).to_fs(:govuk_time), - } - end - - def apply_2_deadline - { - date: CycleTimetable.date(:apply_2_deadline).to_fs(:govuk_date), - time: CycleTimetable.date(:apply_2_deadline).to_fs(:govuk_time), - } - end - def application_form_recruitment_cycle_year @application_form.recruitment_cycle_year end diff --git a/app/services/cycle_timetable.rb b/app/services/cycle_timetable.rb index bac39192617..44cc16d3cbb 100644 --- a/app/services/cycle_timetable.rb +++ b/app/services/cycle_timetable.rb @@ -139,9 +139,8 @@ def self.current_date now end - def self.show_apply_1_deadline_banner?(application_form) - current_date.between?(date(:show_deadline_banner), date(:apply_1_deadline)) && - application_form.phase == 'apply_1' && + def self.show_apply_deadline_banner?(application_form) + current_date.between?(date(:show_deadline_banner), date(:apply_2_deadline)) && !application_form.successful? end @@ -157,11 +156,6 @@ def self.between_reject_by_default_and_find_reopens? current_date.between?(CycleTimetable.reject_by_default, CycleTimetable.find_reopens) end - def self.show_apply_2_deadline_banner?(application_form) - current_date.between?(date(:show_deadline_banner), date(:apply_2_deadline)) && - (application_form.phase == 'apply_2' || (application_form.phase == 'apply_1' && application_form.ended_without_success?)) - end - def self.show_non_working_days_banner? show_christmas_non_working_days_banner? || show_easter_non_working_days_banner? end diff --git a/config/locales/candidate_interface/deadline_banner_component.yml b/config/locales/candidate_interface/deadline_banner_component.yml new file mode 100644 index 00000000000..fd00a849d36 --- /dev/null +++ b/config/locales/candidate_interface/deadline_banner_component.yml @@ -0,0 +1,3 @@ +en: + heading: The deadline for applying to courses starting in %{academic_year} is %{deadline_time} on %{deadline_date} + text: Courses may fill up before then. Check course availability with the provider. diff --git a/spec/components/candidate_interface/deadline_banner_component_spec.rb b/spec/components/candidate_interface/deadline_banner_component_spec.rb index 7b89754a255..e13018275ab 100644 --- a/spec/components/candidate_interface/deadline_banner_component_spec.rb +++ b/spec/components/candidate_interface/deadline_banner_component_spec.rb @@ -7,7 +7,7 @@ it 'does not render when flash is not empty' do allow(flash).to receive(:empty?).and_return(false) - allow(CycleTimetable).to receive_messages(show_apply_1_deadline_banner?: true, show_apply_2_deadline_banner?: true) + allow(CycleTimetable).to receive_messages(show_apply_deadline_banner?: true) result = render_inline(described_class.new(application_form:, flash_empty: flash.empty?)) @@ -16,32 +16,21 @@ it 'does not render when a deadline banner should not be shown' do allow(flash).to receive(:empty?).and_return(true) - allow(CycleTimetable).to receive_messages(show_apply_1_deadline_banner?: false, show_apply_2_deadline_banner?: false) + allow(CycleTimetable).to receive_messages(show_apply_deadline_banner?: false) result = render_inline(described_class.new(application_form:, flash_empty: flash.empty?)) expect(result.text).to eq('') end - it 'renders the Apply 1 banner when the right conditions are met' do + it 'renders the banner when the right conditions are met' do allow(flash).to receive(:empty?).and_return(true) - allow(CycleTimetable).to receive_messages(show_apply_1_deadline_banner?: true, show_apply_2_deadline_banner?: false) + allow(CycleTimetable).to receive_messages(show_apply_deadline_banner?: true) result = render_inline(described_class.new(application_form:, flash_empty: flash.empty?)) expect(result.text).to include( - "The deadline for applying to courses starting in the #{academic_year} academic year is #{deadline_time(:apply_1_deadline)} on #{deadline_date(:apply_1_deadline)}", - ) - end - - it 'renders the Apply 2 banner when the right conditions are met' do - allow(flash).to receive(:empty?).and_return(true) - allow(CycleTimetable).to receive_messages(show_apply_1_deadline_banner?: false, show_apply_2_deadline_banner?: true) - - result = render_inline(described_class.new(application_form:, flash_empty: flash.empty?)) - - expect(result.text).to include( - "The deadline for applying to courses starting in the #{academic_year} academic year is #{deadline_time(:apply_2_deadline)} on #{deadline_date(:apply_2_deadline)}", + "The deadline for applying to courses starting in #{academic_year} is #{deadline_time(:apply_2_deadline)} on #{deadline_date(:apply_2_deadline)}", ) end end diff --git a/spec/services/cycle_timetable_spec.rb b/spec/services/cycle_timetable_spec.rb index d2b6ce06891..c67c9bbb121 100644 --- a/spec/services/cycle_timetable_spec.rb +++ b/spec/services/cycle_timetable_spec.rb @@ -55,20 +55,21 @@ end end - describe '.show_apply_1_deadline_banner?' do - it 'returns true before the configured date and it is an unsuccessful apply_1 application' do - application_form = build(:application_form, phase: 'apply_1') + describe '.show_apply_deadline_banner?' do + it 'returns true before the deadline and the choices have not ben successful' do + application_choices = [build(:application_choice, :withdrawn)] + application_form = build(:application_form, application_choices:) travel_temporarily_to(one_hour_before_apply1_deadline) do - expect(described_class.show_apply_1_deadline_banner?(application_form)).to be true + expect(described_class.show_apply_deadline_banner?(application_form)).to be true end end - it 'returns false if it is a apply_2 application' do - application_form = build(:application_form, phase: 'apply_2') + it 'returns true if there are no application choices' do + application_form = build(:application_form) travel_temporarily_to(one_hour_before_apply1_deadline) do - expect(described_class.show_apply_1_deadline_banner?(application_form)).to be false + expect(described_class.show_apply_deadline_banner?(application_form)).to be true end end @@ -77,15 +78,15 @@ application_form = build(:application_form, phase: 'apply_1', application_choices: [application_choice]) travel_temporarily_to(one_hour_before_apply1_deadline) do - expect(described_class.show_apply_1_deadline_banner?(application_form)).to be false + expect(described_class.show_apply_deadline_banner?(application_form)).to be false end end it 'returns false after the configured date' do application_form = build(:application_form, phase: 'apply_1') - travel_temporarily_to(one_hour_after_apply1_deadline) do - expect(described_class.show_apply_1_deadline_banner?(application_form)).to be false + travel_temporarily_to(one_hour_after_apply2_deadline) do + expect(described_class.show_apply_deadline_banner?(application_form)).to be false end end end @@ -117,33 +118,6 @@ end end - describe '.show_apply_2_deadline_banner?' do - it 'returns true before the configured date and it is a phase 2 application' do - application_form = build(:application_form, phase: 'apply_2') - - travel_temporarily_to(one_hour_before_apply2_deadline) do - expect(described_class.show_apply_2_deadline_banner?(application_form)).to be true - end - end - - it 'returns false if it is a successful apply_1 application' do - application_choice = build(:application_choice, :offered) - application_form = build(:application_form, phase: 'apply_1', application_choices: [application_choice]) - - travel_temporarily_to(one_hour_before_apply2_deadline) do - expect(described_class.show_apply_2_deadline_banner?(application_form)).to be false - end - end - - it 'returns false after the configured date' do - unsuccessful_application_form = build(:application_form, phase: 'apply_2', application_choices: [build(:application_choice, :rejected)]) - - travel_temporarily_to(one_hour_after_apply2_deadline) do - expect(described_class.show_apply_2_deadline_banner?(unsuccessful_application_form)).to be false - end - end - end - describe '.show_non_working_days_banner?' do context 'when within the Christmas period' do let(:one_hour_after_christmas_period) { described_class.holidays[:christmas].last.end_of_day + 1.hour }