Skip to content

Commit

Permalink
Remove overtime status on judge or attorney reassignment
Browse files Browse the repository at this point in the history
  • Loading branch information
hschallhorn committed Jun 2, 2020
1 parent d18185c commit 3cb011e
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/legacy_tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
6 changes: 6 additions & 0 deletions app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 = {})
Expand Down
4 changes: 4 additions & 0 deletions app/models/tasks/attorney_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
4 changes: 4 additions & 0 deletions app/models/tasks/judge_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 25 additions & 0 deletions spec/controllers/legacy_tasks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
58 changes: 58 additions & 0 deletions spec/models/task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3cb011e

Please sign in to comment.