diff --git a/app/controllers/legacy_tasks_controller.rb b/app/controllers/legacy_tasks_controller.rb index 2f68f438334..96e91c7d542 100644 --- a/app/controllers/legacy_tasks_controller.rb +++ b/app/controllers/legacy_tasks_controller.rb @@ -96,6 +96,9 @@ def assign_to_judge # update the location to the assigned judge. QueueRepository.update_location_to_judge(appeal.vacols_id, assigned_to) + # Remove overtime status of an appeal when reassigning to a judge + appeal.overtime = false if appeal.overtime? + render json: { task: json_task(AttorneyLegacyTask.from_vacols( VACOLS::CaseAssignment.latest_task_for_appeal(appeal.vacols_id), diff --git a/app/models/task.rb b/app/models/task.rb index b137d902b01..eba4790cda3 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -517,6 +517,8 @@ def reassign(reassign_params, current_user) update_with_instructions(status: Constants.TASK_STATUSES.cancelled, instructions: reassign_params[:instructions]) + appeal.overtime = false if appeal.overtime? && reassign_clears_overtime? + [sibling, self, sibling.children].flatten end @@ -593,6 +595,10 @@ def cancelled_by User.find_by_id(record.whodunnit) end + def reassign_clears_overtime? + false + end + private def create_and_auto_assign_child_task(options = {}) diff --git a/app/models/tasks/attorney_task.rb b/app/models/tasks/attorney_task.rb index 9e5c44cfa93..fb371b371dc 100644 --- a/app/models/tasks/attorney_task.rb +++ b/app/models/tasks/attorney_task.rb @@ -48,6 +48,10 @@ def stays_with_reassigned_parent? super || completed? end + def reassign_clears_overtime? + true + end + def send_back_to_judge_assign! transaction do cancelled! diff --git a/app/models/tasks/judge_task.rb b/app/models/tasks/judge_task.rb index 455ec14c704..875138f0b67 100644 --- a/app/models/tasks/judge_task.rb +++ b/app/models/tasks/judge_task.rb @@ -41,4 +41,8 @@ def timeline_title def previous_task children_attorney_tasks.order(:assigned_at).last end + + def reassign_clears_overtime? + true + end end diff --git a/spec/controllers/legacy_tasks_controller_spec.rb b/spec/controllers/legacy_tasks_controller_spec.rb index 13e7e0182c6..e382ffcf5b3 100644 --- a/spec/controllers/legacy_tasks_controller_spec.rb +++ b/spec/controllers/legacy_tasks_controller_spec.rb @@ -448,5 +448,30 @@ end it_behaves_like "judge reassigns case" end + + context "When the appeal has not been marked for overtime" do + before { FeatureToggle.enable!(:overtime_revamp) } + after { FeatureToggle.disable!(:overtime_revamp) } + + it "does not create a new work mode for the appeal" do + expect(appeal.work_mode.nil?).to be true + patch :assign_to_judge, params: { tasks: params } + expect(appeal.work_mode.nil?).to be true + end + end + + context "when the appeal has been marked for overtime" do + before do + FeatureToggle.enable!(:overtime_revamp) + appeal.overtime = true + end + after { FeatureToggle.disable!(:overtime_revamp) } + + it "removes the overtime status of the appeal" do + expect(appeal.overtime?).to be true + patch :assign_to_judge, params: { tasks: params } + expect(appeal.reload.overtime?).to be false + end + end end end diff --git a/spec/models/task_spec.rb b/spec/models/task_spec.rb index c35577e418a..4737df2ed14 100644 --- a/spec/models/task_spec.rb +++ b/spec/models/task_spec.rb @@ -897,6 +897,64 @@ end end end + + context "When the appeal has not been marked for overtime" do + let!(:appeal) { create(:appeal) } + let(:task) { create(:ama_judge_assign_task, appeal: appeal) } + + before { FeatureToggle.enable!(:overtime_revamp) } + after { FeatureToggle.disable!(:overtime_revamp) } + + it "does not create a new work mode for the appeal" do + expect(appeal.work_mode.nil?).to be true + subject + expect(appeal.work_mode.nil?).to be true + end + end + + context "When the appeal has been marked for overtime" do + shared_examples "clears overtime" do + it "sets overtime to false" do + expect(appeal.overtime?).to be true + subject + expect(appeal.overtime?).to be false + end + end + + let!(:appeal) { create(:appeal) } + let(:task) { create(:ama_task, appeal: appeal.reload) } + + before do + appeal.overtime = true + FeatureToggle.enable!(:overtime_revamp) + end + after { FeatureToggle.disable!(:overtime_revamp) } + + context "when the task type is not a judge or attorney task" do + it "does not clear the overtime status" do + expect(appeal.overtime?).to be true + subject + expect(appeal.overtime?).to be true + end + end + + context "when the task is a judge task" do + let(:task) { create(:ama_judge_assign_task, appeal: appeal) } + + it_behaves_like "clears overtime" + end + + context "when the task is an attorney task" do + let(:judge) { create(:user, :judge) } + let(:attorney) { create(:user, :attorney) } + let(:new_assignee) { create(:user, :attorney) } + let(:task) { create(:ama_attorney_rewrite_task, assigned_to: attorney, assigned_by: judge, appeal: appeal) } + + subject { task.reassign(params, judge) } + + it_behaves_like "clears overtime" + end + end end describe ".verify_org_task_unique" do