diff --git a/app/components/provider_interface/application_header_components/offer_will_be_declined_by_default_component.html.erb b/app/components/provider_interface/application_header_components/offer_will_be_declined_by_default_component.html.erb index 072b0811f03..67505b05222 100644 --- a/app/components/provider_interface/application_header_components/offer_will_be_declined_by_default_component.html.erb +++ b/app/components/provider_interface/application_header_components/offer_will_be_declined_by_default_component.html.erb @@ -2,5 +2,9 @@ Waiting for candidate’s response

- Your offer will be automatically declined <%= decline_by_default_text %> if the candidate does not respond. + <% if application_choice.continuous_applications? %> + <%= continuous_applications_offer_text %> + <% else %> + Your offer will be automatically declined <%= decline_by_default_text %> if the candidate does not respond. + <% end %>

diff --git a/app/components/provider_interface/application_header_components/offer_will_be_declined_by_default_component.rb b/app/components/provider_interface/application_header_components/offer_will_be_declined_by_default_component.rb index 88ded82a5ea..7eb51de2d6f 100644 --- a/app/components/provider_interface/application_header_components/offer_will_be_declined_by_default_component.rb +++ b/app/components/provider_interface/application_header_components/offer_will_be_declined_by_default_component.rb @@ -1,6 +1,16 @@ module ProviderInterface module ApplicationHeaderComponents class OfferWillBeDeclinedByDefaultComponent < ApplicationChoiceHeaderComponent + def continuous_applications_offer_text + time_since_offer = days_from_now.zero? ? 'today' : "#{pluralize(days_from_now, 'day')} ago" + + "You made this offer #{time_since_offer}. Most candidates respond to offers within 15 working days. The candidate will receive reminders to respond." + end + + def days_from_now + (Time.zone.now.beginning_of_day - application_choice.offered_at.beginning_of_day).to_i / 1.day + end + def decline_by_default_text return unless offer_will_be_declined_by_default? diff --git a/spec/components/provider_interface/application_choice_header_component_spec.rb b/spec/components/provider_interface/application_choice_header_component_spec.rb index fc8cf50d51f..ef0a78f4539 100644 --- a/spec/components/provider_interface/application_choice_header_component_spec.rb +++ b/spec/components/provider_interface/application_choice_header_component_spec.rb @@ -89,7 +89,7 @@ end end - context 'when the application has had an offer' do + context 'when the application has had an offer and it is not continuous applications', continuous_applications: false do let(:dbd_date) { nil } let(:application_choice) { build_stubbed(:application_choice, status: 'offer', decline_by_default_at: dbd_date) } @@ -109,6 +109,28 @@ end end + context 'when the application has had an offer and it is continuous applications', :continuous_applications do + let(:application_choice) { create(:application_choice, :offered) } + + context 'when the offer was made today' do + it 'renders the correct text' do + expect(result.css('.govuk-inset-text > h2').text).to include('Waiting for candidate’s response') + expect(result.css('.govuk-inset-text > p').text).to include('You made this offer today. Most candidates respond to offers within 15 working days. The candidate will receive reminders to respond.') + end + end + + context 'when the offer was made before today' do + before do + application_choice.update(offered_at: 3.days.ago) + end + + it 'renders the correct text' do + expect(result.css('.govuk-inset-text > h2').text).to include('Waiting for candidate’s response') + expect(result.css('.govuk-inset-text > p').text).to include('You made this offer 3 days ago. Most candidates respond to offers within 15 working days. The candidate will receive reminders to respond.') + end + end + end + context 'when the application is awaiting provider decision, reject by default is tomorrow and user cannot make decisions' do let(:provider_can_respond) { false } let(:provider_can_set_up_interviews) { false } diff --git a/spec/components/provider_interface/application_header_components/offer_will_be_declined_by_default_component_spec.rb b/spec/components/provider_interface/application_header_components/offer_will_be_declined_by_default_component_spec.rb index 60baf952be9..986d10eaeab 100644 --- a/spec/components/provider_interface/application_header_components/offer_will_be_declined_by_default_component_spec.rb +++ b/spec/components/provider_interface/application_header_components/offer_will_be_declined_by_default_component_spec.rb @@ -1,55 +1,89 @@ require 'rails_helper' RSpec.describe ProviderInterface::ApplicationHeaderComponents::OfferWillBeDeclinedByDefaultComponent do - describe 'rendered component' do + describe 'rendered component', :continuous_applications do it 'renders offer will be declined content' do application_choice = build_stubbed(:application_choice, :offered) result = render_inline(described_class.new(application_choice:, provider_can_respond: true)) expect(result.css('h2').text.strip).to eq('Waiting for candidate’s response') - expect(result.css('.govuk-body').text).to match(/Your offer will be automatically declined in \d+ days .*? if the candidate does not respond/) + expect(result.css('.govuk-body').text).to match('You made this offer today. Most candidates respond to offers within 15 working days. The candidate will receive reminders to respond.') end end - describe '#decline_by_default_text' do - it 'returns nil if the application is not in the offer state' do - application_choice = build_stubbed(:application_choice, status: 'awaiting_provider_decision') + describe 'rendered component', continuous_applications: false do + it 'renders offer will be declined content' do + application_choice = build_stubbed(:application_choice, :offered) + result = render_inline(described_class.new(application_choice:, provider_can_respond: true)) - expect(described_class.new(application_choice:).decline_by_default_text).to be_nil + expect(result.css('h2').text.strip).to eq('Waiting for candidate’s response') + expect(result.css('.govuk-body').text).to match(/Your offer will be automatically declined in \d+ days .*? if the candidate does not respond/) end + end + + context 'when not continuous applications', continuous_applications: false do + describe '#decline_by_default_text' do + it 'returns nil if the application is not in the offer state' do + application_choice = build_stubbed(:application_choice, status: 'awaiting_provider_decision') - describe 'returns the correct text when' do - it 'the dbd is today' do - application_choice = build_stubbed( - :application_choice, - status: 'offer', - decline_by_default_at: Time.zone.now.end_of_day, - ) + expect(described_class.new(application_choice:).decline_by_default_text).to be_nil + end + + describe 'returns the correct text when' do + it 'the dbd is today' do + application_choice = build_stubbed( + :application_choice, + status: 'offer', + decline_by_default_at: Time.zone.now.end_of_day, + ) + + expected_text = "at the end of today (#{application_choice.decline_by_default_at.to_fs(:govuk_date_and_time)})" + expect(described_class.new(application_choice:).decline_by_default_text).to eq(expected_text) + end + + it 'the dbd is tomorrow' do + application_choice = build_stubbed( + :application_choice, + status: 'offer', + decline_by_default_at: 1.day.from_now.end_of_day, + ) - expected_text = "at the end of today (#{application_choice.decline_by_default_at.to_fs(:govuk_date_and_time)})" - expect(described_class.new(application_choice:).decline_by_default_text).to eq(expected_text) + expected_text = "at the end of tomorrow (#{application_choice.decline_by_default_at.to_fs(:govuk_date_and_time)})" + expect(described_class.new(application_choice:).decline_by_default_text).to eq(expected_text) + end + + it 'the dbd is after tomorrow' do + application_choice = build_stubbed( + :application_choice, + status: 'offer', + decline_by_default_at: 3.days.from_now.end_of_day, + ) + + expected_text = "in 3 days (#{application_choice.decline_by_default_at.to_fs(:govuk_date_and_time)})" + expect(described_class.new(application_choice:).decline_by_default_text).to eq(expected_text) + end end + end + end - it 'the dbd is tomorrow' do - application_choice = build_stubbed( - :application_choice, - status: 'offer', - decline_by_default_at: 1.day.from_now.end_of_day, - ) + context 'when continuous applications', :continuous_applications do + describe '#continuous_applications_offer_text' do + context 'when the offer was made today' do + it 'renders the correct text' do + application_choice = build_stubbed(:application_choice, :continuous_applications, :offered) - expected_text = "at the end of tomorrow (#{application_choice.decline_by_default_at.to_fs(:govuk_date_and_time)})" - expect(described_class.new(application_choice:).decline_by_default_text).to eq(expected_text) + expected_text = 'You made this offer today. Most candidates respond to offers within 15 working days. The candidate will receive reminders to respond.' + expect(described_class.new(application_choice:).continuous_applications_offer_text).to eq(expected_text) + end end - it 'the dbd is after tomorrow' do - application_choice = build_stubbed( - :application_choice, - status: 'offer', - decline_by_default_at: 3.days.from_now.end_of_day, - ) + context 'when the offer was made before today' do + it 'renders the correct text' do + application_choice = build_stubbed(:application_choice, :continuous_applications, :offered, offered_at: 3.days.ago) - expected_text = "in 3 days (#{application_choice.decline_by_default_at.to_fs(:govuk_date_and_time)})" - expect(described_class.new(application_choice:).decline_by_default_text).to eq(expected_text) + expected_text = 'You made this offer 3 days ago. Most candidates respond to offers within 15 working days. The candidate will receive reminders to respond.' + expect(described_class.new(application_choice:).continuous_applications_offer_text).to eq(expected_text) + end end end end