Skip to content

Commit

Permalink
Stop calculating work history after award/decline
Browse files Browse the repository at this point in the history
When an application is awarded or declined, and the work history is
marked as ongoing, we stop counting the number of months when the
application is awarded or declined to ensure the number doesn't keep
increasing.
  • Loading branch information
thomasleese committed Feb 18, 2024
1 parent 9b08622 commit ea9d1ab
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/lib/work_history_duration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def work_history_start_date(work_history)
end

def work_history_end_date(work_history)
work_history.end_date || Time.zone.today
work_history.end_date || application_form.awarded_at ||
application_form.declined_at || Time.zone.today
end

def date_first_of_month(date)
Expand Down
34 changes: 34 additions & 0 deletions spec/lib/work_history_duration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,40 @@
it { is_expected.to eq(7) }
end

context "with an ongoing full time work history and an awarded application form" do
let(:application_form) do
create(:application_form, awarded_at: Date.new(2020, 12, 1))
end

before do
create(
:work_history,
application_form:,
start_date: Date.new(2020, 1, 1),
hours_per_week: 30,
)
end

it { is_expected.to eq(6) }
end

context "with an ongoing full time work history and a declined application form" do
let(:application_form) do
create(:application_form, declined_at: Date.new(2020, 12, 1))
end

before do
create(
:work_history,
application_form:,
start_date: Date.new(2020, 1, 1),
hours_per_week: 30,
)
end

it { is_expected.to eq(6) }
end

context "with an ongoing part time work history" do
before do
create(
Expand Down

0 comments on commit ea9d1ab

Please sign in to comment.