Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PART 3] Remove overtime status of appeal if case is reassigned #14453

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need a feature toggle check here as overtime? returns false if the feature toggle is not enabled


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
24 changes: 18 additions & 6 deletions client/app/queue/AssignToView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import COPY from '../../COPY';

import { taskById, appealWithDetailSelector } from './selectors';

import { onReceiveAmaTasks, legacyReassignToJudge } from './QueueActions';
import { onReceiveAmaTasks, legacyReassignToJudge, setOvertime } from './QueueActions';

import SearchableDropdown from '../components/SearchableDropdown';
import TextareaField from '../components/TextareaField';
import QueueFlowModal from './components/QueueFlowModal';

import { requestPatch, requestSave } from './uiReducer/uiActions';
import { requestPatch, requestSave, resetSuccessMessages } from './uiReducer/uiActions';

import { taskActionData } from './utils';

Expand Down Expand Up @@ -59,6 +59,8 @@ class AssignToView extends React.Component {
};
}

componentDidMount = () => this.props.resetSuccessMessages();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes the below!
Screen Shot 2020-06-04 at 3 03 25 PM


validateForm = () => {
return this.state.selectedValue !== null && this.state.instructions !== '';
};
Expand Down Expand Up @@ -145,6 +147,9 @@ class AssignToView extends React.Component {

return this.props.requestPatch(`/tasks/${task.taskId}`, payload, successMsg).then((resp) => {
this.props.onReceiveAmaTasks(resp.body.tasks.data);
if (task.type === 'JudgeAssignTask') {
this.props.setOvertime(task.externalAppealId, false);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On reassign of a judge assign task: Ensure we update the redux store to reflect that this appeal's overtime status is now false

});
};

Expand Down Expand Up @@ -241,7 +246,8 @@ class AssignToView extends React.Component {

AssignToView.propTypes = {
appeal: PropTypes.shape({
externalId: PropTypes.string
externalId: PropTypes.string,
id: PropTypes.string
}),
assigneeAlreadySelected: PropTypes.bool,
highlightFormItems: PropTypes.bool,
Expand All @@ -254,8 +260,12 @@ AssignToView.propTypes = {
task: PropTypes.shape({
instructions: PropTypes.string,
taskId: PropTypes.string,
availableActions: PropTypes.arrayOf(PropTypes.object)
})
availableActions: PropTypes.arrayOf(PropTypes.object),
externalAppealId: PropTypes.string,
type: PropTypes.string
}),
setOvertime: PropTypes.func,
resetSuccessMessages: PropTypes.func
};

const mapStateToProps = (state, ownProps) => {
Expand All @@ -274,7 +284,9 @@ const mapDispatchToProps = (dispatch) =>
requestPatch,
requestSave,
onReceiveAmaTasks,
legacyReassignToJudge
legacyReassignToJudge,
setOvertime,
resetSuccessMessages
},
dispatch
);
Expand Down
6 changes: 5 additions & 1 deletion client/app/queue/QueueActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export const setOvertime = (appealId, overtime) => ({
appealId,
overtime
}
})
});

export const deleteTask = (taskId) => ({
type: ACTIONS.DELETE_TASK,
Expand Down Expand Up @@ -534,6 +534,8 @@ export const reassignTasksToUser = ({
dispatch(decrementTaskCountForAttorney({
id: previousAssigneeId
}));

dispatch(setOvertime(oldTask.externalAppealId, false));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On reassign of an attorney assign task: Ensure we update the redux store to reflect that this appeal's overtime status is now false

});
}));

Expand All @@ -557,6 +559,8 @@ export const legacyReassignToJudge = ({
dispatch(onReceiveTasks(_.pick(allTasks, ['tasks', 'amaTasks'])));

dispatch(showSuccessMessage(successMessage));

dispatch(setOvertime(oldTask.externalAppealId, false));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On reassign of a legacy judge assign task: Ensure we update the redux store to reflect that this appeal's overtime status is now false

});
}));

Expand Down
2 changes: 2 additions & 0 deletions client/app/queue/components/AssignToAttorneyWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class AssignToAttorneyWidget extends React.PureComponent {
};
}

componentDidMount = () => this.props.resetSuccessMessages();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes the below!
Screen Shot 2020-06-04 at 3 03 25 PM


validAssignee = () => {
const { selectedAssignee } = this.props;

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