Skip to content

Commit 4dee4d7

Browse files
committed
fix: ensure new rollover units are not marked archived
1 parent 378a6c9 commit 4dee4d7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

app/models/unit.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ def rollover(teaching_period, start_date, end_date, new_code)
287287
new_unit.end_date = end_date
288288
end
289289

290+
# Clear archived
291+
new_unit.archived = false
292+
290293
if self.portfolio_auto_generation_date.present?
291294
# Update the portfolio auto generation date to be the same day of the week and week number as the old date
292295
new_unit.portfolio_auto_generation_date = new_unit.date_for_week_and_day(week_number(self.portfolio_auto_generation_date), Date::ABBR_DAYNAMES[self.portfolio_auto_generation_date.wday])

test/models/unit_model_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,11 @@ def test_archive_unit
881881
assert File.exist?(FileHelper.task_submission_identifier_path(:done, task))
882882
assert File.exist?(File.join(FileHelper.task_submission_identifier_path_with_timestamp(:done, task, '123_45'), 'output.txt'))
883883

884+
new_tp = FactoryBot.create :teaching_period
885+
new_unit = unit.rollover(new_tp, nil, nil, nil)
886+
887+
assert_not new_unit.archived
888+
884889
unit.destroy!
885890

886891
assert_not File.exist?(td.task_sheet), "New file exists after delete - #{td.task_sheet}"

0 commit comments

Comments
 (0)