Skip to content

Commit

Permalink
Add back the non continuous application text for DBD component
Browse files Browse the repository at this point in the history
This is for candidates with offers for 2023, they have till ~12th oct
until declined by default.
  • Loading branch information
zarembas committed Oct 9, 2023
1 parent e33fea9 commit f33140e
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
Waiting for candidate’s response
</h2>
<p class="govuk-body">
<%= offer_text %>
<% 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 %>
</p>
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
module ProviderInterface
module ApplicationHeaderComponents
class OfferWillBeDeclinedByDefaultComponent < ApplicationChoiceHeaderComponent
def offer_text
def continuous_applications_offer_text
days = application_choice.days_since_offered

"You made this offer #{days_since(days)}. Most candidates respond to offers within 15 working days. The candidate will receive reminders to respond."
end

def decline_by_default_text
return unless offer_will_be_declined_by_default?

if time_is_today_or_tomorrow?(application_choice.decline_by_default_at)
"at the end of #{date_and_time_today_or_tomorrow(application_choice.decline_by_default_at)}"
else
days_remaining = days_until(application_choice.decline_by_default_at.to_date)
"in #{days_remaining} (#{application_choice.decline_by_default_at.to_fs(:govuk_date_and_time)})"
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,68 @@
end
end

describe '#offer_text' do
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(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')

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 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

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 = '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:).offer_text).to eq(expected_text)
expect(described_class.new(application_choice:).continuous_applications_offer_text).to eq(expected_text)
end
end

Expand All @@ -26,7 +81,7 @@
application_choice = build_stubbed(:application_choice, :continuous_applications, :offered, offered_at: 3.days.ago)

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:).offer_text).to eq(expected_text)
expect(described_class.new(application_choice:).continuous_applications_offer_text).to eq(expected_text)
end
end
end
Expand Down

0 comments on commit f33140e

Please sign in to comment.