diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb index 774be8ab793..262c5032029 100644 --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -89,12 +89,6 @@ def create # { # assigned_to_id: 23 # } - # To update colocated task - # e.g, for ama/legacy appeal => PATCH /tasks/:id, - # { - # status: :on_hold, - # on_hold_duration: "something" - # } def update tasks = task.update_from_params(update_params, current_user) tasks.each { |t| return invalid_record_error(t) unless t.valid? } @@ -224,7 +218,6 @@ def create_params def update_params params.require("task").permit( :status, - :on_hold_duration, :assigned_to_id, :instructions, reassign: [:assigned_to_id, :assigned_to_type, :instructions], diff --git a/app/models/queues/generic_queue.rb b/app/models/queues/generic_queue.rb index 234750f8c3e..adf122e965c 100644 --- a/app/models/queues/generic_queue.rb +++ b/app/models/queues/generic_queue.rb @@ -7,7 +7,7 @@ def initialize(limit: 10_000, user:) end def tasks - (relevant_tasks + relevant_attorney_tasks).each(&:update_if_hold_expired!) + (relevant_tasks + relevant_attorney_tasks) end private diff --git a/app/models/task.rb b/app/models/task.rb index 40e385caceb..d9ce3271d48 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -324,7 +324,7 @@ def calculated_placed_on_hold_at def calculated_on_hold_duration timed_hold_task = active_child_timed_hold_task - (timed_hold_task&.timer_end_time&.to_date &.- timed_hold_task&.timer_start_time&.to_date)&.to_i || on_hold_duration + (timed_hold_task&.timer_end_time&.to_date &.- timed_hold_task&.timer_start_time&.to_date)&.to_i end def update_task_type(params) @@ -529,15 +529,6 @@ def timeline_title "#{type} completed" end - def update_if_hold_expired! - update!(status: Constants.TASK_STATUSES.in_progress) if old_style_hold_expired? - end - - def old_style_hold_expired? - !on_timed_hold? && on_hold? && placed_on_hold_at && on_hold_duration && - (placed_on_hold_at + on_hold_duration.days < Time.zone.now) - end - def serializer_class ::WorkQueue::TaskSerializer end diff --git a/app/models/tasks/hearing_admin_action_task.rb b/app/models/tasks/hearing_admin_action_task.rb index c4f1f7baa38..69854ad066c 100644 --- a/app/models/tasks/hearing_admin_action_task.rb +++ b/app/models/tasks/hearing_admin_action_task.rb @@ -7,7 +7,6 @@ class HearingAdminActionTask < Task validates :parent, presence: true - validate :on_hold_duration_is_set, on: :update def self.child_task_assignee(parent, params) if params[:assigned_to_type] && params[:assigned_to_id] @@ -48,14 +47,6 @@ def available_actions(user) def actions_allowable?(user) (HearingsManagement.singleton.user_has_access?(user) || HearingAdmin.singleton.user_has_access?(user)) && super end - - private - - def on_hold_duration_is_set - if saved_change_to_status? && on_hold? && !on_hold_duration && !on_timed_hold? && assigned_to.is_a?(User) - errors.add(:on_hold_duration, "has to be specified") - end - end end require_dependency "hearing_admin_action_contested_claimant_task" diff --git a/app/models/tasks/timed_hold_task.rb b/app/models/tasks/timed_hold_task.rb index e69a09895f2..239599bfa10 100644 --- a/app/models/tasks/timed_hold_task.rb +++ b/app/models/tasks/timed_hold_task.rb @@ -15,8 +15,7 @@ class TimedHoldTask < Task def self.create_from_parent(parent_task, days_on_hold:, assigned_by: nil, instructions: nil) multi_transaction do if parent_task.is_a?(Task) - # Set on_hold_duration to nil so that we override any old-style holds when we create a new timed hold. - parent_task.update_with_instructions(instructions: instructions, on_hold_duration: nil) + parent_task.update_with_instructions(instructions: instructions) end create!( appeal: parent_task.appeal, diff --git a/app/sql/ama-tasks.sql b/app/sql/ama-tasks.sql index d5f80a21379..1b5c2915f96 100644 --- a/app/sql/ama-tasks.sql +++ b/app/sql/ama-tasks.sql @@ -20,7 +20,6 @@ SELECT "Tasks"."appeal_type" AS TEXT ) AS "appeal_type" ,"Tasks"."placed_on_hold_at" AS "placed_on_hold_at" - ,"Tasks"."on_hold_duration" AS "on_hold_duration" ,CAST ( "Tasks"."assigned_to_type" AS TEXT ) AS "assigned_to_type" diff --git a/client/app/queue/ColocatedPlaceHoldView.jsx b/client/app/queue/ColocatedPlaceHoldView.jsx deleted file mode 100644 index 391831bf088..00000000000 --- a/client/app/queue/ColocatedPlaceHoldView.jsx +++ /dev/null @@ -1,201 +0,0 @@ -import * as React from 'react'; -import PropTypes from 'prop-types'; -import { connect } from 'react-redux'; -import { bindActionCreators } from 'redux'; -import { withRouter } from 'react-router-dom'; -import classNames from 'classnames'; -import { css } from 'glamor'; -import { sprintf } from 'sprintf-js'; - -import COPY from '../../COPY.json'; -import CO_LOCATED_ADMIN_ACTIONS from '../../constants/CO_LOCATED_ADMIN_ACTIONS.json'; - -import { - taskById, - appealWithDetailSelector -} from './selectors'; -import { onReceiveAmaTasks } from './QueueActions'; -import { requestPatch } from './uiReducer/uiActions'; - -import SearchableDropdown from '../components/SearchableDropdown'; -import TextField from '../components/TextField'; -import Alert from '../components/Alert'; -import TextareaField from '../components/TextareaField'; - -import { - fullWidth, - marginBottom, - marginTop, - COLOCATED_HOLD_DURATIONS -} from './constants'; -import QueueFlowPage from './components/QueueFlowPage'; - -class ColocatedPlaceHoldView extends React.Component { - - constructor(props) { - super(props); - - this.state = { - hold: '', - customHold: null, - instructions: '' - }; - } - - validateForm = () => { - if (!COLOCATED_HOLD_DURATIONS.includes(this.state.hold) || this.state.instructions === '') { - return false; - } - if (Number(this.state.hold)) { - return true; - } - if (this.state.hold === 'Custom') { - return Number(this.state.customHold); - } - } - - goToNextStep = () => { - const { - task, - appeal - } = this.props; - const payload = { - data: { - task: { - status: 'on_hold', - on_hold_duration: this.state.customHold || this.state.hold, - instructions: this.state.instructions - } - } - }; - const successMsg = { - title: sprintf( - COPY.COLOCATED_ACTION_PLACE_HOLD_CONFIRMATION, - appeal.veteranFullName, - this.state.customHold || this.state.hold - ), - detail: COPY.COLOCATED_ACTION_PLACE_HOLD_CONFIRMATION_DETAIL - }; - - this.props.requestPatch(`/tasks/${task.taskId}`, payload, successMsg). - then((resp) => { - this.props.onReceiveAmaTasks(resp.body.tasks.data); - }); - } - - render = () => { - const { - task, - error, - appeal, - highlightFormItems, - ...otherProps - } = this.props; - const columnStyling = css({ - width: '50%', - maxWidth: '25rem' - }); - const errorClass = classNames({ - 'usa-input-error': highlightFormItems && !this.state.hold - }); - - return -

- {sprintf(COPY.COLOCATED_ACTION_PLACE_HOLD_HEAD, appeal.veteranFullName, appeal.veteranFileNumber)} -

-
- - Veteran ID: {appeal.veteranFileNumber} - - - Task: {CO_LOCATED_ADMIN_ACTIONS[task.label]} - -
-
- {error && } -

{COPY.COLOCATED_ACTION_PLACE_HOLD_COPY}

-
- option && this.setState({ hold: option.value })} - options={COLOCATED_HOLD_DURATIONS.map((value) => ({ - label: Number(value) ? `${value} days` : value, - value - }))} /> -
- {this.state.hold === 'Custom' && -

{COPY.COLOCATED_ACTION_PLACE_CUSTOM_HOLD_COPY}

-
- this.setState({ customHold })} - errorMessage={highlightFormItems && !this.state.customHold ? - COPY.COLOCATED_ACTION_PLACE_CUSTOM_HOLD_INVALID_VALUE : null - } - label={false} /> -
-
} - this.setState({ instructions })} - styling={marginTop(2)} /> -
; - } -} - -ColocatedPlaceHoldView.propTypes = { - appeal: PropTypes.shape({ - veteranFileNumber: PropTypes.string, - veteranFullName: PropTypes.string - }), - error: PropTypes.shape({ - title: PropTypes.string, - detail: PropTypes.string - }), - highlightFormItems: PropTypes.bool, - onReceiveAmaTasks: PropTypes.func, - requestPatch: PropTypes.func, - task: PropTypes.shape({ - label: PropTypes.string, - taskId: PropTypes.string - }) -}; - -const mapStateToProps = (state, ownProps) => { - const { - highlightFormItems, - messages: { error } - } = state.ui; - - return { - error, - highlightFormItems, - task: taskById(state, { taskId: ownProps.taskId }), - appeal: appealWithDetailSelector(state, ownProps) - }; -}; - -const mapDispatchToProps = (dispatch) => bindActionCreators({ - requestPatch, - onReceiveAmaTasks -}, dispatch); - -export default (withRouter( - connect(mapStateToProps, mapDispatchToProps)(ColocatedPlaceHoldView) -)); diff --git a/client/app/queue/QueueApp.jsx b/client/app/queue/QueueApp.jsx index 7e0ed50fe7e..32b527b40cb 100644 --- a/client/app/queue/QueueApp.jsx +++ b/client/app/queue/QueueApp.jsx @@ -30,7 +30,6 @@ import JudgeDecisionReviewTaskListView from './JudgeDecisionReviewTaskListView'; import JudgeAssignTaskListView from './JudgeAssignTaskListView'; import EvaluateDecisionView from './caseEvaluation/EvaluateDecisionView'; import AddColocatedTaskView from './AddColocatedTaskView'; -import ColocatedPlaceHoldView from './ColocatedPlaceHoldView'; import CompleteTaskModal from './components/CompleteTaskModal'; import UpdateTaskStatusAssignRegionalOfficeModal from './components/UpdateTaskStatusAssignRegionalOfficeModal'; import CancelTaskModal from './components/CancelTaskModal'; @@ -203,8 +202,6 @@ class QueueApp extends React.PureComponent { routedAddColocatedTask = (props) => ; - routedColocatedPlaceHold = (props) => ; - routedAdvancedOnDocketMotion = (props) => ; routedAssignToAttorney = (props) => ; diff --git a/db/seeds.rb b/db/seeds.rb index c9a07386b2e..1dc95995718 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -876,7 +876,6 @@ def create_task_at_judge_review(appeal, judge, attorney) def create_task_at_colocated(appeal, judge, attorney, trait = ColocatedTask.actions_assigned_to_colocated.sample.to_sym) parent = FactoryBot.create( :ama_judge_decision_review_task, - :on_hold, assigned_to: judge, appeal: appeal, parent: create_root_task(appeal) @@ -884,7 +883,6 @@ def create_task_at_colocated(appeal, judge, attorney, trait = ColocatedTask.acti atty_task = FactoryBot.create( :ama_attorney_task, - :on_hold, assigned_to: attorney, assigned_by: judge, parent: parent, @@ -914,7 +912,6 @@ def create_colocated_legacy_tasks(attorney) def create_task_at_attorney_review(appeal, judge, attorney) parent = FactoryBot.create( :ama_judge_decision_review_task, - :on_hold, assigned_to: judge, appeal: appeal, parent: create_root_task(appeal) @@ -1008,7 +1005,6 @@ def create_task_at_bva_dispatch(seed = Faker::Number.number(digits: 3)) FactoryBot.create(:staff, :judge_role, user: judge) judge_task = FactoryBot.create( :ama_judge_decision_review_task, - :on_hold, assigned_to: judge, appeal: appeal, parent: root_task diff --git a/spec/controllers/asyncable_jobs_controller_spec.rb b/spec/controllers/asyncable_jobs_controller_spec.rb index 1df2f83ead0..6d566630c1c 100644 --- a/spec/controllers/asyncable_jobs_controller_spec.rb +++ b/spec/controllers/asyncable_jobs_controller_spec.rb @@ -119,7 +119,7 @@ create(:decision_document, submitted_at: 7.days.ago, attempted_at: 7.days.ago) end let!(:task_timer) do - task = create(:generic_task, :on_hold) + task = create(:generic_task) TaskTimer.create!(task: task, submitted_at: 7.days.ago, attempted_at: 7.days.ago) end diff --git a/spec/controllers/tasks_controller_spec.rb b/spec/controllers/tasks_controller_spec.rb index 09929255f0b..2c3e86f7fc3 100644 --- a/spec/controllers/tasks_controller_spec.rb +++ b/spec/controllers/tasks_controller_spec.rb @@ -29,9 +29,12 @@ let!(:task12) { create(:ama_attorney_task, :in_progress, assigned_to: user) } let!(:task13) { create(:ama_attorney_task, :completed, assigned_to: user) } let!(:task16) { create(:ama_attorney_task, :completed_in_the_past, assigned_to: user) } - let!(:task14) { create(:ama_attorney_task, :on_hold, assigned_to: user) } + let!(:task14) { create(:ama_attorney_task, assigned_to: user) } - before { task3.update!(status: Constants.TASK_STATUSES.completed) } + before do + task3.update!(status: Constants.TASK_STATUSES.completed) + task14.update!(status: Constants.TASK_STATUSES.on_hold) + end it "should process the request successfully" do get :index, params: { user_id: user.id, role: "attorney" } @@ -622,10 +625,7 @@ end it "updates status to on_hold" do - patch :update, params: { - task: { status: Constants.TASK_STATUSES.on_hold, on_hold_duration: 60 }, - id: admin_action.id - } + patch :update, params: { task: { status: Constants.TASK_STATUSES.on_hold }, id: admin_action.id } expect(response.status).to eq 200 response_body = JSON.parse(response.body)["tasks"]["data"] expect(response_body.first["attributes"]["status"]).to eq Constants.TASK_STATUSES.on_hold diff --git a/spec/factories/task.rb b/spec/factories/task.rb index d89fb11474e..8216b65f32c 100644 --- a/spec/factories/task.rb +++ b/spec/factories/task.rb @@ -24,29 +24,14 @@ trait :on_hold do started_at { rand(20..30).days.ago } placed_on_hold_at { rand(1..10).days.ago } - on_hold_duration { [30, 60, 90].sample } after(:create) do |task| - task.update_columns(status: Constants.TASK_STATUSES.on_hold) - task.children.update_all(status: Constants.TASK_STATUSES.on_hold) - end - end - - trait :completed_hold do - started_at { rand(25..30).days.ago } - placed_on_hold_at { rand(15..25).days.ago } - on_hold_duration { 10 } - - after(:create) do |task| - task.update_columns(status: Constants.TASK_STATUSES.on_hold) - task.children.update_all(status: Constants.TASK_STATUSES.on_hold) + TimedHoldTask.create_from_parent(task, days_on_hold: [30, 60, 90].sample) end end trait :completed do started_at { rand(20..30).days.ago } - placed_on_hold_at { rand(1..10).days.ago } - on_hold_duration { [30, 60, 90].sample } closed_at { Time.zone.now } after(:create) do |task| @@ -57,8 +42,6 @@ trait :completed_in_the_past do started_at { rand(20..30).weeks.ago } - placed_on_hold_at { rand(4..10).weeks.ago } - on_hold_duration { [30, 60, 90].sample } after(:create) do |task| task.update_columns(status: Constants.TASK_STATUSES.completed, closed_at: 3.weeks.ago) diff --git a/spec/feature/queue/attorney_queue_spec.rb b/spec/feature/queue/attorney_queue_spec.rb index b0d09f89cd2..2a9ccbcecf2 100644 --- a/spec/feature/queue/attorney_queue_spec.rb +++ b/spec/feature/queue/attorney_queue_spec.rb @@ -34,7 +34,6 @@ let(:attorney_task) do create( :ama_attorney_task, - :on_hold, appeal: appeal, assigned_by: judge, assigned_to: attorney, @@ -167,13 +166,12 @@ let!(:colocated_org_task) do create( :colocated_task, - :on_hold, appeal: appeal, assigned_by: attorney ) end - before { colocated_org_task.children.first.update!(assigned_to: attorney) } + before { colocated_org_task.children.first.update!(assigned_to: attorney, status: :on_hold) } it "displays a single row for the appeal in the attorney's on hold tab" do visit("/queue") diff --git a/spec/feature/queue/colocated_task_queue_spec.rb b/spec/feature/queue/colocated_task_queue_spec.rb index 163665710cd..1aeae5174af 100644 --- a/spec/feature/queue/colocated_task_queue_spec.rb +++ b/spec/feature/queue/colocated_task_queue_spec.rb @@ -126,118 +126,6 @@ expect(page).to have_content("0 of #{hold_duration_days}") end end - - context "when ColocatedTask on old-style hold is updated with a later hold expiration date" do - let(:old_hold_started) { 3.days.ago } - let(:old_hold_duration_days) { 15 } - let(:new_hold_duration_days) { 60 } - - let(:colocated_org_task) do - create( - :ama_colocated_task, - appeal: appeal, - parent: root_task - ) - end - let(:colocated_individual_task) { colocated_org_task.children.first } - - before do - colocated_individual_task.update!( - status: Constants.TASK_STATUSES.on_hold, - on_hold_duration: old_hold_duration_days - ) - - # Update the placed_on_hold_at value in a different statement to avoid it being overwritten by set_timestamps. - colocated_individual_task.update!(placed_on_hold_at: old_hold_started) - end - - it "wipes out the old hold and updates the task with new hold information" do - User.authenticate!(user: vlj_support_staff) - visit("/queue/appeals/#{appeal.uuid}") - - # Confirm old hold information is set. - expect(colocated_individual_task.status).to eq(Constants.TASK_STATUSES.on_hold) - expect(colocated_individual_task.calculated_placed_on_hold_at).to eq(old_hold_started) - expect(colocated_individual_task.calculated_on_hold_duration).to eq(old_hold_duration_days) - - # Place task on hold again. - click_dropdown(text: Constants.TASK_ACTIONS.PLACE_TIMED_HOLD.label) - expect(page).to have_content(Constants.TASK_ACTIONS.PLACE_TIMED_HOLD.label) - click_dropdown( - prompt: COPY::COLOCATED_ACTION_PLACE_HOLD_LENGTH_SELECTOR_LABEL, - text: "#{new_hold_duration_days} days" - ) - fill_in("instructions", with: "some text") - click_on(COPY::MODAL_SUBMIT_BUTTON) - - expect(page).to have_content( - format(COPY::COLOCATED_ACTION_PLACE_HOLD_CONFIRMATION, veteran_name, new_hold_duration_days) - ) - expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") - - # Task snapshot updated with new hold information - expect(page).to have_content("0 of #{new_hold_duration_days}") - end - end - - context "when ColocatedTask on old-style hold is updated with an earlier hold expiration date" do - let(:old_hold_started) { 3.days.ago } - let(:old_hold_duration_days) { 90 } - let(:new_hold_duration_days) { 45 } - - let(:colocated_org_task) do - create( - :ama_colocated_task, - appeal: appeal, - parent: root_task - ) - end - let(:colocated_individual_task) { colocated_org_task.children.first } - - before do - colocated_individual_task.update!( - status: Constants.TASK_STATUSES.on_hold, - on_hold_duration: old_hold_duration_days - ) - - # Update the placed_on_hold_at value in a different statement to avoid it being overwritten by set_timestamps. - colocated_individual_task.update!(placed_on_hold_at: old_hold_started) - end - - it "wipes out the old hold and updates the task with new hold information" do - User.authenticate!(user: vlj_support_staff) - visit("/queue/appeals/#{appeal.uuid}") - - # Confirm old hold information is set. - expect(colocated_individual_task.status).to eq(Constants.TASK_STATUSES.on_hold) - expect(colocated_individual_task.calculated_placed_on_hold_at).to eq(old_hold_started) - expect(colocated_individual_task.calculated_on_hold_duration).to eq(old_hold_duration_days) - - # Place task on hold again. - click_dropdown(text: Constants.TASK_ACTIONS.PLACE_TIMED_HOLD.label) - expect(page).to have_content(Constants.TASK_ACTIONS.PLACE_TIMED_HOLD.label) - click_dropdown( - prompt: COPY::COLOCATED_ACTION_PLACE_HOLD_LENGTH_SELECTOR_LABEL, - text: "#{new_hold_duration_days} days" - ) - fill_in("instructions", with: "some text") - click_on(COPY::MODAL_SUBMIT_BUTTON) - - expect(page).to have_content( - format(COPY::COLOCATED_ACTION_PLACE_HOLD_CONFIRMATION, veteran_name, new_hold_duration_days) - ) - expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") - - # Values in database are correct. - colocated_individual_task.reload - expect(colocated_individual_task.status).to eq(Constants.TASK_STATUSES.on_hold) - expect(colocated_individual_task.calculated_placed_on_hold_at).to_not eq(old_hold_started) - expect(colocated_individual_task.calculated_on_hold_duration).to eq(new_hold_duration_days) - - # Task snapshot updated with new hold information - expect(page).to have_content("0 of #{new_hold_duration_days}") - end - end end describe "vlj support staff changes task type" do diff --git a/spec/feature/queue/task_queue_spec.rb b/spec/feature/queue/task_queue_spec.rb index b6957722d33..cf3f5239c31 100644 --- a/spec/feature/queue/task_queue_spec.rb +++ b/spec/feature/queue/task_queue_spec.rb @@ -965,7 +965,6 @@ def validate_pulac_cerullo_tasks_created(task_class, label) let!(:orig_judge_task) do create( :ama_judge_decision_review_task, - :on_hold, assigned_to: judge_user, appeal: appeal, parent: root_task diff --git a/spec/models/queues/generic_queue_spec.rb b/spec/models/queues/generic_queue_spec.rb deleted file mode 100644 index 74f5c02ec3d..00000000000 --- a/spec/models/queues/generic_queue_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -describe GenericQueue, :all_dbs do - describe "#tasks" do - let(:atty) { create(:user) } - let!(:vacols_atty) { create(:staff, :attorney_role, sdomainid: atty.css_id) } - let(:user) { create(:user) } - let!(:on_hold_task) do - create( - :colocated_task, - :on_hold, - assigned_by: atty, - assigned_to: user, - on_hold_duration: 3 - ) - end - let(:task_count) { 5 } - - before { create_list(:colocated_task, task_count, :in_progress, assigned_by: atty, assigned_to: user) } - - context "when some on hold tasks have expired" do - it "should set the status of the expired task to in_progress" do - on_hold_task.update(placed_on_hold_at: 15.days.ago) - tasks = GenericQueue.new(user: user).tasks - expect(tasks.size).to eq(task_count + 1) - - expired_on_hold_task = tasks.detect { |t| t.id == on_hold_task.id } - expect(expired_on_hold_task.status).to eq("in_progress") - end - end - end -end diff --git a/spec/models/serializers/work_queue/task_serializer_spec.rb b/spec/models/serializers/work_queue/task_serializer_spec.rb index 31fdd2a3ed9..19309068fad 100644 --- a/spec/models/serializers/work_queue/task_serializer_spec.rb +++ b/spec/models/serializers/work_queue/task_serializer_spec.rb @@ -25,16 +25,5 @@ expect(subject[:on_hold_duration]).to eq days_on_hold end end - - context "when setting on hold values on the task itself" do - before do - parent.update!(status: Constants.TASK_STATUSES.on_hold, on_hold_duration: days_on_hold) - end - - it "renders the correct values for an on hold task" do - expect(subject[:placed_on_hold_at]).to eq now - expect(subject[:on_hold_duration]).to eq days_on_hold - end - end end end diff --git a/spec/models/task_spec.rb b/spec/models/task_spec.rb index 3bf77f7bb97..b519f20b46c 100644 --- a/spec/models/task_spec.rb +++ b/spec/models/task_spec.rb @@ -3,7 +3,7 @@ describe Task, :all_dbs do context "includes PrintsTaskTree concern" do describe ".structure" do - let(:root_task) { create(:root_task, :on_hold) } + let(:root_task) { create(:root_task) } let!(:bva_task) { create(:bva_dispatch_task, :in_progress, parent: root_task) } let(:judge_task) { create(:ama_judge_task, :completed, parent: root_task) } let!(:attorney_task) { create(:ama_attorney_task, :completed, parent: judge_task) } @@ -37,10 +37,11 @@ end describe ".when_child_task_completed" do - let(:task) { create(:task, :on_hold, type: Task.name) } - let(:child) { create(:task, :completed, type: Task.name, parent: task) } + let(:task) { create(:task, type: Task.name) } + let(:child_status) { :assigned } + let!(:child) { create(:task, child_status, type: Task.name, parent: task) } - subject { task.when_child_task_completed(child) } + subject { task.reload.when_child_task_completed(child) } context "when on_hold task is assigned to a person" do context "when task has no child tasks" do @@ -54,7 +55,7 @@ end context "when task has 1 incomplete child task" do - let(:child) { create(:task, :in_progress, type: Task.name, parent_id: task.id) } + let!(:child_status) { :in_progress } it "should not change the task's status" do status_before = task.status @@ -64,7 +65,7 @@ end context "when task has 1 complete child task" do - let(:child) { create(:task, :completed, type: Task.name, parent_id: task.id) } + let!(:child_status) { :completed } it "should change task's status to assigned" do status_before = task.status @@ -75,8 +76,7 @@ end context "when task is already closed" do - let!(:task) { create(:task, :on_hold, type: Task.name) } - let!(:child) { create(:task, :completed, type: Task.name, parent: task) } + let!(:child_status) { :completed } before { task.update!(status: Constants.TASK_STATUSES.completed) } @@ -88,10 +88,6 @@ context "when task has some complete and some incomplete child tasks" do let!(:completed_children) { create_list(:task, 3, :completed, type: Task.name, parent_id: task.id) } - let(:incomplete_children) do - create_list(:task, 2, :in_progress, type: Task.name, parent_id: task.id) - end - let(:child) { incomplete_children.last } it "should not change the task's status" do status_before = task.status @@ -102,10 +98,10 @@ context "when task has only complete child tasks" do let(:completed_children) { create_list(:task, 3, :completed, type: Task.name, parent_id: task.id) } - let(:child) { completed_children.last } + let!(:child) { completed_children.last } it "should change task's status to assigned" do - status_before = task.status + status_before = task.reload.status subject expect(task.status).to_not eq(status_before) expect(task.status).to eq("assigned") @@ -115,7 +111,7 @@ context "when on_hold task is assigned to an organization" do let(:organization) { Organization.create!(name: "Other organization", url: "other") } - let(:task) { create(:task, :on_hold, type: Task.name, assigned_to: organization) } + let(:task) { create(:task, type: Task.name, assigned_to: organization) } context "when task has no child tasks" do let(:child) { nil } @@ -128,7 +124,7 @@ end context "when task has 1 incomplete child task" do - let(:child) { create(:task, :in_progress, type: Task.name, parent_id: task.id) } + let(:child_status) { :in_progress } it "should not update any attribute of the task" do task_status = task.status @@ -138,7 +134,7 @@ end context "when task has 1 complete child task" do - let(:child) { create(:task, :completed, type: Task.name, parent_id: task.id) } + let(:child_status) { :completed } it "should update the task" do subject @@ -147,8 +143,7 @@ end context "when task is already closed" do - let!(:task) { create(:task, :on_hold, type: Task.name, assigned_to: organization) } - let!(:child) { create(:task, :completed, type: Task.name, parent: task) } + let(:child_status) { :completed } before { task.update!(status: Constants.TASK_STATUSES.completed) } @@ -160,10 +155,6 @@ context "when task has some complete and some incomplete child tasks" do let!(:completed_children) { create_list(:task, 3, :completed, type: Task.name, parent_id: task.id) } - let(:incomplete_children) do - create_list(:task, 2, :in_progress, type: Task.name, parent_id: task.id) - end - let(:child) { incomplete_children.last } it "should not update any attribute of the task" do task_status = task.status @@ -174,7 +165,7 @@ context "when task has only complete child tasks" do let(:completed_children) { create_list(:task, 3, :completed, type: Task.name, parent_id: task.id) } - let(:child) { completed_children.last } + let!(:child) { completed_children.last } it "should update the task" do subject @@ -184,6 +175,7 @@ context "when child task has a different type than parent" do let!(:child) { create(:quality_review_task, :completed, parent_id: task.id) } + it "sets the status of the parent to assigned" do subject expect(task.reload.status).to eq(Constants.TASK_STATUSES.assigned) @@ -560,18 +552,6 @@ end end - describe "#actions_available?" do - let(:user) { create(:user) } - - context "when task status is on_hold" do - let(:task) { create(:generic_task, :on_hold) } - - it "returns false" do - expect(task.actions_available?(user)).to eq(false) - end - end - end - describe "#actions_allowable?" do let(:user) { create(:user) } @@ -832,36 +812,6 @@ def next_assignee(_options = {}) end end - describe ".old_style_hold_expired?" do - subject { task.old_style_hold_expired? } - - context "when a task is on an active old-style hold" do - let(:task) { create(:task, :on_hold) } - - it "recognizes that the old style hold has not expired" do - expect(subject).to eq(false) - end - end - - context "when a task has completed an old-style hold" do - let(:task) { create(:task, :on_hold) } - - it "recognizes that the old style hold has expired" do - task.update(placed_on_hold_at: 200.days.ago) - expect(subject).to eq(true) - end - end - - context "when a task has a completed old-style hold as well as a new timed hold" do - let(:task) { create(:task, :on_hold, placed_on_hold_at: 200.days.ago) } - before { TimedHoldTask.create_from_parent(task, days_on_hold: 16) } - - it "does not recognize that the task has completed the old-style hold" do - expect(subject).to eq(false) - end - end - end - describe ".assigned_to_same_org?" do subject { task.assigned_to_same_org?(other_task) } diff --git a/spec/models/tasks/assign_hearing_disposition_task_spec.rb b/spec/models/tasks/assign_hearing_disposition_task_spec.rb index b22a35b8a42..c1923a086de 100644 --- a/spec/models/tasks/assign_hearing_disposition_task_spec.rb +++ b/spec/models/tasks/assign_hearing_disposition_task_spec.rb @@ -435,7 +435,6 @@ no_show_hearing_task = NoShowHearingTask.first expect(no_show_hearing_task).to_not be_nil expect(no_show_hearing_task.placed_on_hold_at).to_not be_nil - expect(no_show_hearing_task.old_style_hold_expired?).to be_falsey expect(no_show_hearing_task.reload.on_hold?).to be_truthy expect(no_show_hearing_task.calculated_on_hold_duration).to eq 25 instructions_text = "Mail must be received within 14 days of the original hearing date." diff --git a/spec/models/tasks/colocated_task_spec.rb b/spec/models/tasks/colocated_task_spec.rb index 9dfa24d2732..b3ec3057772 100644 --- a/spec/models/tasks/colocated_task_spec.rb +++ b/spec/models/tasks/colocated_task_spec.rb @@ -323,13 +323,13 @@ time3 = Time.utc(2015, 1, 5, 12, 0, 0) Timecop.freeze(time3) - colocated_admin_action.update(status: "on_hold", on_hold_duration: 30) + colocated_admin_action.update(status: "on_hold") expect(colocated_admin_action.reload.started_at).to eq time1 expect(colocated_admin_action.placed_on_hold_at).to eq time3 time4 = Time.utc(2015, 1, 6, 12, 0, 0) Timecop.freeze(time4) - colocated_admin_action.update(status: "on_hold", on_hold_duration: 30) + colocated_admin_action.update(status: "on_hold") # neither dates should change expect(colocated_admin_action.reload.started_at).to eq time1 expect(colocated_admin_action.placed_on_hold_at).to eq time3 diff --git a/spec/models/tasks/distribution_task_spec.rb b/spec/models/tasks/distribution_task_spec.rb index e2b1050d3e6..fa5e072fa70 100644 --- a/spec/models/tasks/distribution_task_spec.rb +++ b/spec/models/tasks/distribution_task_spec.rb @@ -13,15 +13,12 @@ let(:distribution_task) do create( :distribution_task, - :on_hold, appeal: create(:appeal), assigned_to: Bva.singleton ) end it "is set to assigned and ready for distribution is tracked when all child tasks are completed" do - expect(distribution_task.ready_for_distribution?).to eq(false) - child_task = create(:informal_hearing_presentation_task, parent: distribution_task) expect(distribution_task.ready_for_distribution?).to eq(false) diff --git a/spec/models/tasks/generic_task_spec.rb b/spec/models/tasks/generic_task_spec.rb index e746d0d05f8..492b4f88fc7 100644 --- a/spec/models/tasks/generic_task_spec.rb +++ b/spec/models/tasks/generic_task_spec.rb @@ -170,13 +170,14 @@ describe ".available_actions_unwrapper" do let(:user) { create(:user) } - let(:task) { create(:generic_task, trait, assigned_to: assignee) } + let(:task) { create(:generic_task, :completed, assigned_to: assignee) } + subject { task.available_actions_unwrapper(user) } context "when task assigned to the user is has been completed" do let(:assignee) { user } - let(:trait) { :completed } let(:expected_actions) { [] } + it "should return an empty list" do expect(subject).to eq(expected_actions) end @@ -184,9 +185,13 @@ context "when task assigned to an organization the user is a member of is on hold" do let(:assignee) { Organization.find(create(:organization).id) } - let(:trait) { :on_hold } let(:expected_actions) { [] } - before { allow_any_instance_of(Organization).to receive(:user_has_access?).and_return(true) } + + before do + allow_any_instance_of(Organization).to receive(:user_has_access?).and_return(true) + task.update!(status: :on_hold) + end + it "should return an empty list" do expect(subject).to eq(expected_actions) end diff --git a/spec/models/tasks/timed_hold_task_spec.rb b/spec/models/tasks/timed_hold_task_spec.rb index c53990e7fdf..dbd543976a0 100644 --- a/spec/models/tasks/timed_hold_task_spec.rb +++ b/spec/models/tasks/timed_hold_task_spec.rb @@ -153,7 +153,7 @@ end context "when the TimedHoldTask has a parent task assigned to an organization" do - let(:parent_task) { create(:generic_task, :on_hold) } + let(:parent_task) { create(:generic_task) } let(:task) { create(:timed_hold_task, trait, parent: parent_task) } it "sets the parent task status to assigned" do subject diff --git a/spec/workflows/bulk_task_reassignment_spec.rb b/spec/workflows/bulk_task_reassignment_spec.rb index 8dc18ee808c..f673b0a1dde 100644 --- a/spec/workflows/bulk_task_reassignment_spec.rb +++ b/spec/workflows/bulk_task_reassignment_spec.rb @@ -8,7 +8,7 @@ let(:task_count) { 4 } let(:parent_assignee) { create(:organization) } let(:parent_task_type) { :task } - let(:parent_tasks) { create_list(parent_task_type, task_count, :on_hold, assigned_to: parent_assignee) } + let(:parent_tasks) { create_list(parent_task_type, task_count, assigned_to: parent_assignee) } let(:task_type) { :task } let!(:tasks) do