From 9e8c9ca8f21b5161e72363ec906757d8abb75c63 Mon Sep 17 00:00:00 2001 From: yoomlam Date: Wed, 4 Mar 2020 07:00:38 -0600 Subject: [PATCH 1/4] set task's appeal consistently --- spec/factories/task.rb | 78 +++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/spec/factories/task.rb b/spec/factories/task.rb index e056b74fd75..b1ec14720f4 100644 --- a/spec/factories/task.rb +++ b/spec/factories/task.rb @@ -67,7 +67,7 @@ factory :distribution_task, class: DistributionTask do type { DistributionTask.name } - appeal { create(:appeal) } + appeal assigned_by { nil } assigned_to { Bva.singleton } @@ -79,17 +79,17 @@ factory :ama_task, class: Task do type { Task.name } - appeal { create(:appeal) } + appeal end factory :pulac_cerullo_task, class: PulacCerulloTask do type { PulacCerulloTask.name } - appeal { create(:appeal) } + appeal end factory :privacy_act_task, class: PrivacyActTask do type { PrivacyActTask.name } - appeal { create(:appeal) } + appeal end factory :foia_task, class: FoiaTask do @@ -99,7 +99,7 @@ factory :timed_hold_task, class: TimedHoldTask do type { TimedHoldTask.name } - appeal { create(:appeal) } + appeal assigned_to { create(:user) } days_on_hold { rand(1..100) } parent { create(:ama_task) } @@ -110,7 +110,7 @@ assigned_to { Colocated.singleton } factory :ama_colocated_task, traits: [ColocatedTask.actions_assigned_to_colocated.sample.to_sym] do - appeal { create(:appeal) } + appeal end trait :ihp do @@ -289,100 +289,100 @@ factory :ama_judge_task, class: JudgeAssignTask do type { JudgeAssignTask.name } - appeal { create(:appeal) } + appeal end factory :assign_hearing_disposition_task, class: AssignHearingDispositionTask do type { AssignHearingDispositionTask.name } assigned_to { Bva.singleton } - appeal { create(:appeal) } + appeal parent { create(:hearing_task) } end factory :change_hearing_disposition_task, class: ChangeHearingDispositionTask do type { ChangeHearingDispositionTask.name } assigned_to { HearingAdmin.singleton } - appeal { create(:appeal) } + appeal end factory :ama_judge_decision_review_task, class: JudgeDecisionReviewTask do type { JudgeDecisionReviewTask.name } - appeal { create(:appeal) } + appeal end factory :ama_judge_quality_review_task, class: JudgeQualityReviewTask do type { JudgeQualityReviewTask.name } - appeal { create(:appeal) } + appeal end factory :ama_judge_dispatch_return_task, class: JudgeDispatchReturnTask do type { JudgeDispatchReturnTask.name } - appeal { create(:appeal) } + appeal parent { create(:root_task, appeal: appeal) } end factory :track_veteran_task, class: TrackVeteranTask do type { TrackVeteranTask.name } - appeal { create(:appeal) } + appeal end factory :translation_task, class: TranslationTask do type { TranslationTask.name } - appeal { create(:appeal) } + appeal end factory :hearing_task, class: HearingTask do type { HearingTask.name } assigned_to { Bva.singleton } - appeal { create(:appeal) } + appeal parent { appeal.root_task || create(:root_task, appeal: appeal) } end factory :schedule_hearing_task, class: ScheduleHearingTask do type { ScheduleHearingTask.name } - appeal { create(:appeal) } + appeal assigned_to { Bva.singleton } parent { create(:hearing_task, appeal: appeal) } end factory :appeal_withdrawal_mail_task, class: AppealWithdrawalMailTask do type { AppealWithdrawalMailTask.name } - appeal { create(:appeal) } + appeal assigned_to { MailTeam.singleton } parent { create(:root_task, appeal: appeal) } end factory :appeal_withdrawal_bva_task, class: AppealWithdrawalMailTask do type { AppealWithdrawalMailTask.name } - appeal { create(:appeal) } + appeal assigned_to { BvaIntake.singleton } parent { create(:appeal_withdrawal_mail_task, appeal: appeal) } end factory :returned_undeliverable_correspondence_mail_task, class: ReturnedUndeliverableCorrespondenceMailTask do type { ReturnedUndeliverableCorrespondenceMailTask.name } - appeal { create(:appeal) } + appeal assigned_to { BvaDispatch.singleton } parent { create(:root_task, appeal: appeal) } end factory :no_show_hearing_task, class: NoShowHearingTask do type { NoShowHearingTask.name } - appeal { create(:appeal) } + appeal assigned_to { HearingsManagement.singleton } parent { create(:assign_hearing_disposition_task, appeal: appeal) } end factory :evidence_submission_window_task, class: EvidenceSubmissionWindowTask do type { EvidenceSubmissionWindowTask.name } - appeal { create(:appeal) } + appeal assigned_to { MailTeam.singleton } parent { create(:assign_hearing_disposition_task, appeal: appeal) } end factory :ama_attorney_task, class: AttorneyTask do type { AttorneyTask.name } - appeal { create(:appeal) } + appeal parent { create(:ama_judge_decision_review_task) } assigned_by { create(:user) } assigned_to { create(:user) } @@ -404,32 +404,32 @@ factory :ama_attorney_rewrite_task, class: AttorneyRewriteTask do type { AttorneyRewriteTask.name } - appeal { create(:appeal) } + appeal parent { create(:ama_judge_decision_review_task) } end factory :ama_judge_dispatch_return_to_attorney_task, class: AttorneyDispatchReturnTask do type { AttorneyDispatchReturnTask.name } - appeal { create(:appeal) } + appeal parent { create(:ama_judge_decision_review_task) } end factory :transcription_task, class: TranscriptionTask do type { TranscriptionTask.name } - appeal { create(:appeal) } + appeal parent { create(:root_task, appeal: appeal) } assigned_to { TranscriptionTeam.singleton } end factory :ama_vso_task, class: Task do type { Task.name } - appeal { create(:appeal) } + appeal parent { create(:root_task) } end factory :qr_task, class: QualityReviewTask do type { QualityReviewTask.name } - appeal { create(:appeal) } + appeal parent { create(:root_task) } assigned_by { nil } assigned_to { QualityReview.singleton } @@ -437,37 +437,37 @@ factory :quality_review_task, class: QualityReviewTask do type { QualityReviewTask.name } - appeal { create(:appeal) } + appeal assigned_by { nil } end factory :bva_dispatch_task, class: BvaDispatchTask do type { BvaDispatchTask.name } - appeal { create(:appeal) } + appeal assigned_by { nil } end factory :hearing_admin_action_task, class: HearingAdminActionTask do type { HearingAdminActionTask.name } - appeal { create(:appeal) } + appeal assigned_by { nil } end factory :hearing_admin_action_incarcerated_veteran_task, class: HearingAdminActionIncarceratedVeteranTask do type { HearingAdminActionIncarceratedVeteranTask.name } - appeal { create(:appeal) } + appeal assigned_by { nil } end factory :hearing_admin_action_verify_address_task, class: HearingAdminActionVerifyAddressTask do type { HearingAdminActionVerifyAddressTask.name } - appeal { create(:appeal) } + appeal assigned_by { nil } end factory :informal_hearing_presentation_task, class: InformalHearingPresentationTask do type { InformalHearingPresentationTask.name } - appeal { create(:appeal) } + appeal assigned_by { nil } end @@ -485,20 +485,20 @@ factory :board_grant_effectuation_task, class: BoardGrantEffectuationTask do type { BoardGrantEffectuationTask.name } - appeal { create(:appeal) } + appeal assigned_by { nil } end factory :veteran_record_request_task, class: VeteranRecordRequest do type { VeteranRecordRequest.name } - appeal { create(:appeal) } + appeal parent { create(:root_task) } assigned_by { nil } end factory :aod_motion_mail_task, class: AodMotionMailTask do type { AodMotionMailTask.name } - appeal { create(:appeal) } + appeal parent { create(:root_task) } assigned_to { MailTeam.singleton } assigned_by { nil } @@ -506,7 +506,7 @@ factory :reconsideration_motion_mail_task, class: ReconsiderationMotionMailTask do type { ReconsiderationMotionMailTask.name } - appeal { create(:appeal) } + appeal parent { create(:root_task) } assigned_to { MailTeam.singleton } assigned_by { nil } @@ -514,14 +514,14 @@ factory :vacate_motion_mail_task, class: VacateMotionMailTask do type { VacateMotionMailTask.name } - appeal { create(:appeal) } + appeal parent { create(:root_task) } assigned_to { LitigationSupport.singleton } end factory :congressional_interest_mail_task, class: CongressionalInterestMailTask do type { CongressionalInterestMailTask.name } - appeal { create(:appeal) } + appeal parent { create(:root_task) } assigned_to { MailTeam.singleton } assigned_by { nil } From e66d65bc9cacf871959d9a3bb0464508d17967d0 Mon Sep 17 00:00:00 2001 From: yoomlam Date: Wed, 4 Mar 2020 07:24:54 -0600 Subject: [PATCH 2/4] move outlier away from those that fit a pattern --- spec/factories/task.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/factories/task.rb b/spec/factories/task.rb index b1ec14720f4..b6712c970fd 100644 --- a/spec/factories/task.rb +++ b/spec/factories/task.rb @@ -58,6 +58,18 @@ end end + factory :appeal_task, class: DecisionReviewTask do + type { DecisionReviewTask.name } + appeal { create(:appeal, benefit_type: "education") } + assigned_by { nil } + end + + factory :higher_level_review_task, class: DecisionReviewTask do + type { DecisionReviewTask.name } + appeal { create(:higher_level_review, benefit_type: "education") } + assigned_by { nil } + end + factory :root_task, class: RootTask do type { RootTask.name } appeal @@ -471,18 +483,6 @@ assigned_by { nil } end - factory :appeal_task, class: DecisionReviewTask do - type { DecisionReviewTask.name } - appeal { create(:appeal, benefit_type: "education") } - assigned_by { nil } - end - - factory :higher_level_review_task, class: DecisionReviewTask do - type { DecisionReviewTask.name } - appeal { create(:higher_level_review, benefit_type: "education") } - assigned_by { nil } - end - factory :board_grant_effectuation_task, class: BoardGrantEffectuationTask do type { BoardGrantEffectuationTask.name } appeal From a5f39dad47cae028aabc320315c66c1a080a52bf Mon Sep 17 00:00:00 2001 From: Yoom Lam <55255674+yoomlam@users.noreply.github.com> Date: Thu, 12 Mar 2020 14:26:10 -0500 Subject: [PATCH 3/4] Fix dislocated parent tasks in FactoryBot - Part 2 (#13605) * collect ama tasks together * group all ama tasks under a common parent factory * make it DRY * Fix dislocated parent tasks in FactoryBot - Part 3 (#13606) * DRY it up by setting task.type based on declared `class` * set attributes before saving task record * use ama_task as the parent factory * Fix dislocated parent tasks in FactoryBot - Part 4 (#13607) * create parent tasks to be in the same appeal * check parent task consistency * create the task in the parent's appeal * temporarily disable the check * fix tests * address deprecation warning * add warnings * move task that create their own appeal under ama_task * remove warnings * add code comment for diagnosis if tests fail * Fix dislocated parent tasks in FactoryBot - Part 5 (#13620) * trial to see how many tests fail * test colocated_task having no parent * fix some tests with Kat * check if any tests would produce this warning * don't leave colocated_task type selection to chance * always pass appeal when creating parent task * fix extra appeal created due to overriding appeal * pass the task as the parent, not the id * pass the task as the parent, not the id * don't pass appeal if parent task is provided * pass parent task so the created task is in same appeal * pass actual parent task, not id * increase counts to account for colocated's parent * pass appeal when creating root_task * add comments; adjust failure message * reload task to see it's new children --- .../judge_assign_tasks_controller_spec.rb | 2 +- spec/controllers/tasks_controller_spec.rb | 10 +- spec/factories/task.rb | 502 ++++++++---------- spec/feature/queue/ama_queue_spec.rb | 5 +- .../queue/attorney_checkout_flow_spec.rb | 6 +- spec/feature/queue/case_details_spec.rb | 5 +- .../feature/queue/judge_checkout_flow_spec.rb | 6 +- spec/feature/queue/task_queue_spec.rb | 2 +- spec/feature/withdrawn_request_issues_spec.rb | 4 +- .../fetch_documents_for_reader_user_spec.rb | 2 +- .../hearing_disposition_change_job_spec.rb | 4 +- .../organization_assigned_tasks_tab_spec.rb | 4 +- .../organization_on_hold_tasks_tab_spec.rb | 4 +- spec/models/queues/attorney_queue_spec.rb | 3 +- spec/models/task_pager_spec.rb | 2 +- spec/models/task_sorter_spec.rb | 2 +- spec/models/task_spec.rb | 41 +- spec/models/tasks/colocated_task_spec.rb | 3 +- spec/workflows/bulk_task_reassignment_spec.rb | 10 +- .../fetch_documents_for_reader_spec.rb | 2 +- 20 files changed, 276 insertions(+), 343 deletions(-) diff --git a/spec/controllers/judge_assign_tasks_controller_spec.rb b/spec/controllers/judge_assign_tasks_controller_spec.rb index 178aabe8474..eebdf4320af 100644 --- a/spec/controllers/judge_assign_tasks_controller_spec.rb +++ b/spec/controllers/judge_assign_tasks_controller_spec.rb @@ -9,7 +9,7 @@ let!(:judge_staff) { create(:staff, :judge_role, sdomainid: judge.css_id) } let!(:second_judge_staff) { create(:staff, :judge_role, sdomainid: second_judge.css_id) } - let!(:assign_tasks) { create_list(:ama_judge_task, 3, assigned_to: judge, parent: create(:root_task)) } + let!(:assign_tasks) { Array.new(3) { create(:ama_judge_task, assigned_to: judge, parent: create(:root_task)) } } let!(:assignee) { attorney } let!(:params) do assign_tasks.map do |assign_task| diff --git a/spec/controllers/tasks_controller_spec.rb b/spec/controllers/tasks_controller_spec.rb index e1aded81d34..2467f326fd8 100644 --- a/spec/controllers/tasks_controller_spec.rb +++ b/spec/controllers/tasks_controller_spec.rb @@ -185,7 +185,7 @@ end get :index, params: { user_id: user.id, role: "unknown" } - expect(response).to have_http_status(:success) + expect(response).to be_successful data = JSON.parse(response.body)["tasks"]["data"] @@ -634,16 +634,14 @@ it "updates status to completed" do expect(admin_action.versions.length).to be 0 - expect(admin_action.parent.versions.length).to be 1 patch :update, params: { task: { status: Constants.TASK_STATUSES.completed }, 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.completed expect(response_body.first["attributes"]["closed_at"]).to_not be nil expect(admin_action.reload.versions.length).to eq 1 - expect(admin_action.parent.versions.length).to eq 2 versions = PaperTrail::Version.where(request_id: admin_action.versions.first.request_id) - expect(versions.length).to eq 3 + expect(versions.length).to eq 1 end context "when some other user updates another user's task" do @@ -801,7 +799,7 @@ assert_response :success response_body = JSON.parse(response.body) - expect(response_body["tasks"].length).to eq 2 + expect(response_body["tasks"].length).to eq 3 colocated_task = response_body["tasks"].find { |task| task["attributes"]["type"] == "IhpColocatedTask" } expect(colocated_task).to_not be_nil @@ -828,7 +826,7 @@ expect(task["attributes"]["assigned_to"]["css_id"]).to eq vso_user.css_id expect(task["attributes"]["appeal_id"]).to eq appeal.id - expect(appeal.tasks.size).to eq 3 + expect(appeal.tasks.size).to eq 5 end end end diff --git a/spec/factories/task.rb b/spec/factories/task.rb index b6712c970fd..e237578af3e 100644 --- a/spec/factories/task.rb +++ b/spec/factories/task.rb @@ -1,13 +1,30 @@ # frozen_string_literal: true FactoryBot.define do + # By default, this task is created in a new Legacy appeal factory :task do assigned_at { rand(30..35).days.ago } association :assigned_by, factory: :user association :assigned_to, factory: :user - appeal { create(:legacy_appeal, vacols_case: create(:case)) } type { Task.name } + # if a parent is specified, make sure to use that parent's appeal + appeal { @overrides[:parent] ? @overrides[:parent].appeal : create(:legacy_appeal, vacols_case: create(:case)) } + + after(:create) do |task, _evaluator| + if task.parent + if task.parent&.appeal_id != task.appeal_id + fail "Parent task #{task.parent&.id} is in a different appeal than child task #{task.id}" + end + + # appeal_id may happen to be the same in the test env, so check the appeal_type as well + if task.parent&.appeal_type != task.appeal_type + fail "Parent task #{task.parent&.id} has different appeal_type #{task.parent&.appeal_type} " \ + "than child task's appeal_type #{task.id} #{task.appeal_type}" + end + end + end + trait :assigned do status { Constants.TASK_STATUSES.assigned } end @@ -58,73 +75,12 @@ end end - factory :appeal_task, class: DecisionReviewTask do - type { DecisionReviewTask.name } - appeal { create(:appeal, benefit_type: "education") } - assigned_by { nil } - end - - factory :higher_level_review_task, class: DecisionReviewTask do - type { DecisionReviewTask.name } - appeal { create(:higher_level_review, benefit_type: "education") } - assigned_by { nil } - end - - factory :root_task, class: RootTask do - type { RootTask.name } - appeal - assigned_by { nil } - assigned_to { Bva.singleton } - end - - factory :distribution_task, class: DistributionTask do - type { DistributionTask.name } - appeal - assigned_by { nil } - assigned_to { Bva.singleton } - - after(:create) do |task| - task.update(status: Constants.TASK_STATUSES.on_hold) - task.children.update_all(status: Constants.TASK_STATUSES.on_hold) - end - end - - factory :ama_task, class: Task do - type { Task.name } - appeal - end - - factory :pulac_cerullo_task, class: PulacCerulloTask do - type { PulacCerulloTask.name } - appeal - end - - factory :privacy_act_task, class: PrivacyActTask do - type { PrivacyActTask.name } - appeal - end - - factory :foia_task, class: FoiaTask do - appeal - type { FoiaTask.name } - end - - factory :timed_hold_task, class: TimedHoldTask do - type { TimedHoldTask.name } - appeal - assigned_to { create(:user) } - days_on_hold { rand(1..100) } - parent { create(:ama_task) } - end - + # Colocated tasks for Legacy appeals factory :colocated_task, traits: [ColocatedTask.actions_assigned_to_colocated.sample.to_sym] do - parent { create(:ama_task) } + # don't expect to have a parent for LegacyAppeals + parent { nil } assigned_to { Colocated.singleton } - factory :ama_colocated_task, traits: [ColocatedTask.actions_assigned_to_colocated.sample.to_sym] do - appeal - end - trait :ihp do initialize_with { IhpColocatedTask.new(attributes) } type { IhpColocatedTask.name } @@ -299,260 +255,246 @@ end end - factory :ama_judge_task, class: JudgeAssignTask do - type { JudgeAssignTask.name } - appeal - end + # Tasks for AMA appeals + factory :ama_task, class: Task do + # Use undocumented `@overrides` to check if a parent is specified when `create` is called. + # https://bit.ly/38IjzV6: + # > Though not documented (and therefore even more subject to change) you can access the + # > overridden parameters in the instance variable @overrides. + # It's a clean solution that doesn't require updating tests or adding a new transient attribute. + appeal { @overrides[:parent] ? @overrides[:parent].appeal : create(:appeal) } + + before :create do |task, _eval| + task.update(type: task.class.name) + end - factory :assign_hearing_disposition_task, class: AssignHearingDispositionTask do - type { AssignHearingDispositionTask.name } - assigned_to { Bva.singleton } - appeal - parent { create(:hearing_task) } - end + # Uses parent factory `:colocated_task` + factory :ama_colocated_task, traits: [ColocatedTask.actions_assigned_to_colocated.sample.to_sym], + parent: :colocated_task do + parent { create(:ama_task, appeal: appeal) } + end - factory :change_hearing_disposition_task, class: ChangeHearingDispositionTask do - type { ChangeHearingDispositionTask.name } - assigned_to { HearingAdmin.singleton } - appeal - end + factory :root_task, class: RootTask do + assigned_by { nil } + assigned_to { Bva.singleton } + end - factory :ama_judge_decision_review_task, class: JudgeDecisionReviewTask do - type { JudgeDecisionReviewTask.name } - appeal - end + factory :appeal_task, class: DecisionReviewTask do + appeal { create(:appeal, benefit_type: "education") } + assigned_by { nil } + end - factory :ama_judge_quality_review_task, class: JudgeQualityReviewTask do - type { JudgeQualityReviewTask.name } - appeal - end + factory :higher_level_review_task, class: DecisionReviewTask do + appeal { create(:higher_level_review, benefit_type: "education") } + assigned_by { nil } + end - factory :ama_judge_dispatch_return_task, class: JudgeDispatchReturnTask do - type { JudgeDispatchReturnTask.name } - appeal - parent { create(:root_task, appeal: appeal) } - end + factory :distribution_task, class: DistributionTask do + assigned_by { nil } + assigned_to { Bva.singleton } - factory :track_veteran_task, class: TrackVeteranTask do - type { TrackVeteranTask.name } - appeal - end + after(:create) do |task| + task.update(status: Constants.TASK_STATUSES.on_hold) + task.children.update_all(status: Constants.TASK_STATUSES.on_hold) + end + end - factory :translation_task, class: TranslationTask do - type { TranslationTask.name } - appeal - end + factory :pulac_cerullo_task, class: PulacCerulloTask do + end - factory :hearing_task, class: HearingTask do - type { HearingTask.name } - assigned_to { Bva.singleton } - appeal - parent { appeal.root_task || create(:root_task, appeal: appeal) } - end + factory :privacy_act_task, class: PrivacyActTask do + end - factory :schedule_hearing_task, class: ScheduleHearingTask do - type { ScheduleHearingTask.name } - appeal - assigned_to { Bva.singleton } - parent { create(:hearing_task, appeal: appeal) } - end + factory :foia_task, class: FoiaTask do + end - factory :appeal_withdrawal_mail_task, class: AppealWithdrawalMailTask do - type { AppealWithdrawalMailTask.name } - appeal - assigned_to { MailTeam.singleton } - parent { create(:root_task, appeal: appeal) } - end + factory :timed_hold_task, class: TimedHoldTask do + assigned_to { create(:user) } + days_on_hold { rand(1..100) } + parent { create(:ama_task, appeal: appeal) } + end - factory :appeal_withdrawal_bva_task, class: AppealWithdrawalMailTask do - type { AppealWithdrawalMailTask.name } - appeal - assigned_to { BvaIntake.singleton } - parent { create(:appeal_withdrawal_mail_task, appeal: appeal) } - end + factory :ama_judge_task, class: JudgeAssignTask do + end - factory :returned_undeliverable_correspondence_mail_task, class: ReturnedUndeliverableCorrespondenceMailTask do - type { ReturnedUndeliverableCorrespondenceMailTask.name } - appeal - assigned_to { BvaDispatch.singleton } - parent { create(:root_task, appeal: appeal) } - end + factory :assign_hearing_disposition_task, class: AssignHearingDispositionTask do + assigned_to { Bva.singleton } + parent { create(:hearing_task, appeal: appeal) } + end - factory :no_show_hearing_task, class: NoShowHearingTask do - type { NoShowHearingTask.name } - appeal - assigned_to { HearingsManagement.singleton } - parent { create(:assign_hearing_disposition_task, appeal: appeal) } - end + factory :change_hearing_disposition_task, class: ChangeHearingDispositionTask do + assigned_to { HearingAdmin.singleton } + end - factory :evidence_submission_window_task, class: EvidenceSubmissionWindowTask do - type { EvidenceSubmissionWindowTask.name } - appeal - assigned_to { MailTeam.singleton } - parent { create(:assign_hearing_disposition_task, appeal: appeal) } - end + factory :ama_judge_decision_review_task, class: JudgeDecisionReviewTask do + end - factory :ama_attorney_task, class: AttorneyTask do - type { AttorneyTask.name } - appeal - parent { create(:ama_judge_decision_review_task) } - assigned_by { create(:user) } - assigned_to { create(:user) } - - after(:build) do |_task, evaluator| - if evaluator.assigned_by - existing_staff_record = VACOLS::Staff.where( - sdomainid: evaluator.assigned_by.css_id, svlj: "J", sactive: "A" - ).first - create(:staff, :judge_role, user: evaluator.assigned_by) if existing_staff_record.blank? - end + factory :ama_judge_quality_review_task, class: JudgeQualityReviewTask do + end + + factory :ama_judge_dispatch_return_task, class: JudgeDispatchReturnTask do + parent { create(:root_task, appeal: appeal) } + end + + factory :track_veteran_task, class: TrackVeteranTask do + end + + factory :translation_task, class: TranslationTask do + end + + factory :hearing_task, class: HearingTask do + assigned_to { Bva.singleton } + parent { appeal.root_task || create(:root_task, appeal: appeal) } + end + + factory :schedule_hearing_task, class: ScheduleHearingTask do + assigned_to { Bva.singleton } + parent { create(:hearing_task, appeal: appeal) } + end + + factory :appeal_withdrawal_mail_task, class: AppealWithdrawalMailTask do + assigned_to { MailTeam.singleton } + parent { create(:root_task, appeal: appeal) } + end + + factory :appeal_withdrawal_bva_task, class: AppealWithdrawalMailTask do + assigned_to { BvaIntake.singleton } + parent { create(:appeal_withdrawal_mail_task, appeal: appeal) } + end + + factory :returned_undeliverable_correspondence_mail_task, class: ReturnedUndeliverableCorrespondenceMailTask do + assigned_to { BvaDispatch.singleton } + parent { create(:root_task, appeal: appeal) } + end + + factory :no_show_hearing_task, class: NoShowHearingTask do + assigned_to { HearingsManagement.singleton } + parent { create(:assign_hearing_disposition_task, appeal: appeal) } + end + + factory :evidence_submission_window_task, class: EvidenceSubmissionWindowTask do + assigned_to { MailTeam.singleton } + parent { create(:assign_hearing_disposition_task, appeal: appeal) } + end - if evaluator.assigned_to - existing_staff_record = VACOLS::Staff.where(sdomainid: evaluator.assigned_to.css_id, sactive: "A").first - create(:staff, :attorney_role, user: evaluator.assigned_to) if existing_staff_record.blank? + factory :ama_attorney_task, class: AttorneyTask do + parent { create(:ama_judge_decision_review_task, appeal: appeal) } + assigned_by { create(:user) } + assigned_to { create(:user) } + + after(:build) do |_task, evaluator| + if evaluator.assigned_by + existing_staff_record = VACOLS::Staff.where( + sdomainid: evaluator.assigned_by.css_id, svlj: "J", sactive: "A" + ).first + create(:staff, :judge_role, user: evaluator.assigned_by) if existing_staff_record.blank? + end + + if evaluator.assigned_to + existing_staff_record = VACOLS::Staff.where(sdomainid: evaluator.assigned_to.css_id, sactive: "A").first + create(:staff, :attorney_role, user: evaluator.assigned_to) if existing_staff_record.blank? + end end end - end - factory :ama_attorney_rewrite_task, class: AttorneyRewriteTask do - type { AttorneyRewriteTask.name } - appeal - parent { create(:ama_judge_decision_review_task) } - end + factory :ama_attorney_rewrite_task, class: AttorneyRewriteTask do + parent { create(:ama_judge_decision_review_task, appeal: appeal) } + end - factory :ama_judge_dispatch_return_to_attorney_task, class: AttorneyDispatchReturnTask do - type { AttorneyDispatchReturnTask.name } - appeal - parent { create(:ama_judge_decision_review_task) } - end + factory :ama_judge_dispatch_return_to_attorney_task, class: AttorneyDispatchReturnTask do + parent { create(:ama_judge_decision_review_task, appeal: appeal) } + end - factory :transcription_task, class: TranscriptionTask do - type { TranscriptionTask.name } - appeal - parent { create(:root_task, appeal: appeal) } - assigned_to { TranscriptionTeam.singleton } - end + factory :transcription_task, class: TranscriptionTask do + parent { create(:root_task, appeal: appeal) } + assigned_to { TranscriptionTeam.singleton } + end - factory :ama_vso_task, class: Task do - type { Task.name } - appeal - parent { create(:root_task) } - end + factory :ama_vso_task, class: Task do + parent { create(:root_task, appeal: appeal) } + end - factory :qr_task, class: QualityReviewTask do - type { QualityReviewTask.name } - appeal - parent { create(:root_task) } - assigned_by { nil } - assigned_to { QualityReview.singleton } - end + factory :qr_task, class: QualityReviewTask do + parent { create(:root_task, appeal: appeal) } + assigned_by { nil } + assigned_to { QualityReview.singleton } + end - factory :quality_review_task, class: QualityReviewTask do - type { QualityReviewTask.name } - appeal - assigned_by { nil } - end + factory :quality_review_task, class: QualityReviewTask do + assigned_by { nil } + end - factory :bva_dispatch_task, class: BvaDispatchTask do - type { BvaDispatchTask.name } - appeal - assigned_by { nil } - end + factory :bva_dispatch_task, class: BvaDispatchTask do + assigned_by { nil } + end - factory :hearing_admin_action_task, class: HearingAdminActionTask do - type { HearingAdminActionTask.name } - appeal - assigned_by { nil } - end + factory :hearing_admin_action_task, class: HearingAdminActionTask do + assigned_by { nil } + end - factory :hearing_admin_action_incarcerated_veteran_task, class: HearingAdminActionIncarceratedVeteranTask do - type { HearingAdminActionIncarceratedVeteranTask.name } - appeal - assigned_by { nil } - end + factory :hearing_admin_action_incarcerated_veteran_task, class: HearingAdminActionIncarceratedVeteranTask do + assigned_by { nil } + end - factory :hearing_admin_action_verify_address_task, class: HearingAdminActionVerifyAddressTask do - type { HearingAdminActionVerifyAddressTask.name } - appeal - assigned_by { nil } - end + factory :hearing_admin_action_verify_address_task, class: HearingAdminActionVerifyAddressTask do + assigned_by { nil } + end - factory :informal_hearing_presentation_task, class: InformalHearingPresentationTask do - type { InformalHearingPresentationTask.name } - appeal - assigned_by { nil } - end + factory :informal_hearing_presentation_task, class: InformalHearingPresentationTask do + assigned_by { nil } + end - factory :board_grant_effectuation_task, class: BoardGrantEffectuationTask do - type { BoardGrantEffectuationTask.name } - appeal - assigned_by { nil } - end + factory :board_grant_effectuation_task, class: BoardGrantEffectuationTask do + assigned_by { nil } + end - factory :veteran_record_request_task, class: VeteranRecordRequest do - type { VeteranRecordRequest.name } - appeal - parent { create(:root_task) } - assigned_by { nil } - end + factory :veteran_record_request_task, class: VeteranRecordRequest do + parent { create(:root_task, appeal: appeal) } + assigned_by { nil } + end - factory :aod_motion_mail_task, class: AodMotionMailTask do - type { AodMotionMailTask.name } - appeal - parent { create(:root_task) } - assigned_to { MailTeam.singleton } - assigned_by { nil } - end + factory :aod_motion_mail_task, class: AodMotionMailTask do + parent { create(:root_task, appeal: appeal) } + assigned_to { MailTeam.singleton } + assigned_by { nil } + end - factory :reconsideration_motion_mail_task, class: ReconsiderationMotionMailTask do - type { ReconsiderationMotionMailTask.name } - appeal - parent { create(:root_task) } - assigned_to { MailTeam.singleton } - assigned_by { nil } - end + factory :reconsideration_motion_mail_task, class: ReconsiderationMotionMailTask do + parent { create(:root_task, appeal: appeal) } + assigned_to { MailTeam.singleton } + assigned_by { nil } + end - factory :vacate_motion_mail_task, class: VacateMotionMailTask do - type { VacateMotionMailTask.name } - appeal - parent { create(:root_task) } - assigned_to { LitigationSupport.singleton } - end + factory :vacate_motion_mail_task, class: VacateMotionMailTask do + parent { create(:root_task, appeal: appeal) } + assigned_to { LitigationSupport.singleton } + end - factory :congressional_interest_mail_task, class: CongressionalInterestMailTask do - type { CongressionalInterestMailTask.name } - appeal - parent { create(:root_task) } - assigned_to { MailTeam.singleton } - assigned_by { nil } - end + factory :congressional_interest_mail_task, class: CongressionalInterestMailTask do + parent { create(:root_task, appeal: appeal) } + assigned_to { MailTeam.singleton } + assigned_by { nil } + end - factory :judge_address_motion_to_vacate_task, class: JudgeAddressMotionToVacateTask do - type { JudgeAddressMotionToVacateTask.name } - appeal - association :parent, factory: :vacate_motion_mail_task - end + factory :judge_address_motion_to_vacate_task, class: JudgeAddressMotionToVacateTask do + parent { create(:vacate_motion_mail_task, appeal: appeal) } + end - factory :abstract_motion_to_vacate_task, class: AbstractMotionToVacateTask do - type { AbstractMotionToVacateTask.name } - appeal - association :parent, factory: :vacate_motion_mail_task - end + factory :abstract_motion_to_vacate_task, class: AbstractMotionToVacateTask do + parent { create(:vacate_motion_mail_task, appeal: appeal) } + end - factory :denied_motion_to_vacate_task, class: DeniedMotionToVacateTask do - type { DeniedMotionToVacateTask.name } - appeal - association :parent, factory: :abstract_motion_to_vacate_task - assigned_by { create(:user, full_name: "Judge User", css_id: "JUDGE_1") } - assigned_to { create(:user, full_name: "Motions Attorney", css_id: "LIT_SUPPORT_ATTY_1") } - end + factory :denied_motion_to_vacate_task, class: DeniedMotionToVacateTask do + parent { create(:abstract_motion_to_vacate_task, appeal: appeal) } + assigned_by { create(:user, full_name: "Judge User", css_id: "JUDGE_1") } + assigned_to { create(:user, full_name: "Motions Attorney", css_id: "LIT_SUPPORT_ATTY_1") } + end - factory :dismissed_motion_to_vacate_task, class: DismissedMotionToVacateTask do - type { DismissedMotionToVacateTask.name } - appeal - association :parent, factory: :abstract_motion_to_vacate_task - assigned_by { create(:user, full_name: "Judge User", css_id: "JUDGE_1") } - assigned_to { create(:user, full_name: "Motions Attorney", css_id: "LIT_SUPPORT_ATTY_1") } + factory :dismissed_motion_to_vacate_task, class: DismissedMotionToVacateTask do + parent { create(:abstract_motion_to_vacate_task, appeal: appeal) } + assigned_by { create(:user, full_name: "Judge User", css_id: "JUDGE_1") } + assigned_to { create(:user, full_name: "Motions Attorney", css_id: "LIT_SUPPORT_ATTY_1") } + end end end end diff --git a/spec/feature/queue/ama_queue_spec.rb b/spec/feature/queue/ama_queue_spec.rb index e44ec9950d6..cb9175c2faf 100644 --- a/spec/feature/queue/ama_queue_spec.rb +++ b/spec/feature/queue/ama_queue_spec.rb @@ -72,9 +72,9 @@ def valid_document_id let(:poa_address) { "123 Poplar St." } let(:participant_id) { "600153863" } - let!(:root_task) { create(:root_task) } + let!(:root_task) { create(:root_task, appeal: appeals.first) } let!(:parent_task) do - create(:ama_judge_task, assigned_to: judge_user, appeal: appeals.first, parent: root_task) + create(:ama_judge_task, assigned_to: judge_user, parent: root_task) end let(:poa_name) { "Test POA" } @@ -120,7 +120,6 @@ def valid_document_id assigned_to: attorney_user, assigned_by: judge_user, parent: parent_task, - appeal: appeals.first ), create( :ama_attorney_task, diff --git a/spec/feature/queue/attorney_checkout_flow_spec.rb b/spec/feature/queue/attorney_checkout_flow_spec.rb index a8c25611145..4ee0c0221ce 100644 --- a/spec/feature/queue/attorney_checkout_flow_spec.rb +++ b/spec/feature/queue/attorney_checkout_flow_spec.rb @@ -12,11 +12,10 @@ context "given a valid ama appeal" do before do - root_task = create(:root_task) + root_task = create(:root_task, appeal: appeal) parent_task = create( :ama_judge_decision_review_task, assigned_to: judge_user, - appeal: appeal, parent: root_task ) @@ -25,8 +24,7 @@ :in_progress, assigned_to: attorney_user, assigned_by: judge_user, - parent: parent_task, - appeal: appeal + parent: parent_task ) User.authenticate!(user: attorney_user) diff --git a/spec/feature/queue/case_details_spec.rb b/spec/feature/queue/case_details_spec.rb index 6d5866020b9..1424708899d 100644 --- a/spec/feature/queue/case_details_spec.rb +++ b/spec/feature/queue/case_details_spec.rb @@ -1047,14 +1047,13 @@ describe "case timeline" do context "when the only completed task is a TrackVeteranTask" do - let(:root_task) { create(:root_task) } - let(:appeal) { root_task.appeal } + let(:appeal) { create(:appeal) } let!(:tracking_task) do create( :track_veteran_task, :completed, appeal: appeal, - parent: root_task + parent: appeal.root_task ) end diff --git a/spec/feature/queue/judge_checkout_flow_spec.rb b/spec/feature/queue/judge_checkout_flow_spec.rb index c430d8f9ed2..17899ae8abe 100644 --- a/spec/feature/queue/judge_checkout_flow_spec.rb +++ b/spec/feature/queue/judge_checkout_flow_spec.rb @@ -27,13 +27,12 @@ end let!(:decision_issue) { create(:decision_issue, decision_review: appeal, request_issues: appeal.request_issues) } - let(:root_task) { create(:root_task) } + let(:root_task) { create(:root_task, appeal: appeal) } let(:parent_task) do create( :ama_judge_decision_review_task, :in_progress, assigned_to: judge_user, - appeal: appeal, parent: root_task ) end @@ -44,8 +43,7 @@ :in_progress, assigned_to: attorney_user, assigned_by: judge_user, - parent: parent_task, - appeal: appeal + parent: parent_task ) end diff --git a/spec/feature/queue/task_queue_spec.rb b/spec/feature/queue/task_queue_spec.rb index d03e2f159f4..4af8c6a62d4 100644 --- a/spec/feature/queue/task_queue_spec.rb +++ b/spec/feature/queue/task_queue_spec.rb @@ -557,7 +557,7 @@ def validate_pulac_cerullo_tasks_created(task_class, label) allow_any_instance_of(Organization).to receive(:use_task_pages_api?).and_return(true) Task.on_hold.where(assigned_to_type: Organization.name, assigned_to_id: organization.id) .each_with_index do |task, idx| - child_task = create(:ama_task, parent_id: task.id) + child_task = create(:ama_task, parent: task) child_task.update!(status: Constants.TASK_STATUSES.on_hold) if idx < on_hold_count end Task.active.where(assigned_to_type: Organization.name, assigned_to_id: organization.id) diff --git a/spec/feature/withdrawn_request_issues_spec.rb b/spec/feature/withdrawn_request_issues_spec.rb index 0dcc816a336..ead4a74153a 100644 --- a/spec/feature/withdrawn_request_issues_spec.rb +++ b/spec/feature/withdrawn_request_issues_spec.rb @@ -80,7 +80,6 @@ def create_ama_attorney_task assigned_to: attorney, assigned_by: judge, parent: parent_task, - appeal: appeal ) end @@ -96,8 +95,7 @@ def parent_task create( :ama_judge_decision_review_task, assigned_to: judge, - appeal: appeal, - parent: create(:root_task) + parent: create(:root_task, appeal: appeal) ) end diff --git a/spec/jobs/fetch_documents_for_reader_user_spec.rb b/spec/jobs/fetch_documents_for_reader_user_spec.rb index 314d11320af..ecc4ae6b423 100644 --- a/spec/jobs/fetch_documents_for_reader_user_spec.rb +++ b/spec/jobs/fetch_documents_for_reader_user_spec.rb @@ -70,7 +70,7 @@ end let!(:task) do create( - :colocated_task, + :ama_colocated_task, assigned_to: create(:user), assigned_by: user, appeal: ama_appeal diff --git a/spec/jobs/hearing_disposition_change_job_spec.rb b/spec/jobs/hearing_disposition_change_job_spec.rb index e9929d46800..60c6cddbc56 100644 --- a/spec/jobs/hearing_disposition_change_job_spec.rb +++ b/spec/jobs/hearing_disposition_change_job_spec.rb @@ -74,10 +74,10 @@ def create_disposition_task_for_legacy_hearings_ancestry(associated_hearing: nil # Property: Class that subclasses DispositionTask. context "when there are ChangeHearingDispositionTasks" do let!(:disposition_tasks) do - create_list(:assign_hearing_disposition_task, 6, parent: create(:hearing_task)) + Array.new(6) { create(:assign_hearing_disposition_task, parent: create(:hearing_task)) } end let!(:change_disposition_tasks) do - create_list(:change_hearing_disposition_task, 3, parent: create(:hearing_task)) + Array.new(3) { create(:change_hearing_disposition_task, parent: create(:hearing_task)) } end it "only returns the AssignHearingDispositionTasks" do diff --git a/spec/models/queue_tabs/organization_assigned_tasks_tab_spec.rb b/spec/models/queue_tabs/organization_assigned_tasks_tab_spec.rb index fc41b5ef3b1..41ad216fea7 100644 --- a/spec/models/queue_tabs/organization_assigned_tasks_tab_spec.rb +++ b/spec/models/queue_tabs/organization_assigned_tasks_tab_spec.rb @@ -44,8 +44,8 @@ let!(:assignee_on_hold_tasks) { create_list(:ama_task, 3, :assigned, assigned_to: assignee) } let!(:on_hold_tasks_children) do assignee_on_hold_tasks.map do |task| - create(:ama_task, :in_progress, parent_id: task.id) - create(:timed_hold_task, :assigned, parent_id: task.id) + create(:ama_task, :in_progress, parent: task) + create(:timed_hold_task, :assigned, parent: task) task.update!(status: Constants.TASK_STATUSES.on_hold) task.children end.flatten diff --git a/spec/models/queue_tabs/organization_on_hold_tasks_tab_spec.rb b/spec/models/queue_tabs/organization_on_hold_tasks_tab_spec.rb index 7d77b923dd8..c41e058dd6e 100644 --- a/spec/models/queue_tabs/organization_on_hold_tasks_tab_spec.rb +++ b/spec/models/queue_tabs/organization_on_hold_tasks_tab_spec.rb @@ -44,8 +44,8 @@ let!(:assignee_on_hold_tasks) { create_list(:ama_task, 3, :assigned, assigned_to: assignee) } let!(:on_hold_tasks_children) do assignee_on_hold_tasks.map do |task| - create(:ama_task, parent_id: task.id) - create(:timed_hold_task, parent_id: task.id) + create(:ama_task, parent: task) + create(:timed_hold_task, parent: task) task.descendants.each(&:on_hold!) task.children end.flatten diff --git a/spec/models/queues/attorney_queue_spec.rb b/spec/models/queues/attorney_queue_spec.rb index ec4531023b3..6c9e0a0bb6a 100644 --- a/spec/models/queues/attorney_queue_spec.rb +++ b/spec/models/queues/attorney_queue_spec.rb @@ -17,10 +17,11 @@ let(:org1) { Colocated.singleton } let!(:action1) { create(:colocated_task, assigned_by: user, assigned_to: org1) } let(:org2) { Colocated.singleton } - let!(:action2) { create(:colocated_task, appeal: appeal, assigned_by: user, assigned_to: org2) } + let!(:action2) { create(:colocated_task, :ihp, appeal: appeal, assigned_by: user, assigned_to: org2) } let!(:action3) do create( :colocated_task, + :poa_clarification, appeal: appeal, assigned_by: user ).tap do |task| diff --git a/spec/models/task_pager_spec.rb b/spec/models/task_pager_spec.rb index a2650a358a4..0c8c21f2d6e 100644 --- a/spec/models/task_pager_spec.rb +++ b/spec/models/task_pager_spec.rb @@ -377,7 +377,7 @@ end appeals = [appeal_1, appeal_2] appeals.map do |appeal| - create(:colocated_task, assigned_to: assignee, appeal: appeal) + create(:ama_colocated_task, assigned_to: assignee, appeal: appeal) create(:cached_appeal, appeal_id: appeal.id, appeal_type: Appeal.name, diff --git a/spec/models/task_sorter_spec.rb b/spec/models/task_sorter_spec.rb index 882dea1649c..1d5d9803184 100644 --- a/spec/models/task_sorter_spec.rb +++ b/spec/models/task_sorter_spec.rb @@ -300,7 +300,7 @@ appeals = [create(:appeal, :advanced_on_docket_due_to_motion), create(:appeal)] appeals.each do |appeal| - create(:colocated_task, appeal: appeal, assigned_to: org) + create(:ama_colocated_task, appeal: appeal, assigned_to: org) create(:cached_appeal, appeal_id: appeal.id, appeal_type: Appeal.name, diff --git a/spec/models/task_spec.rb b/spec/models/task_spec.rb index 10be611b352..f2904553674 100644 --- a/spec/models/task_spec.rb +++ b/spec/models/task_spec.rb @@ -43,23 +43,23 @@ subject { ama_task.post_dispatch_task? } context "dispatch task is not complete" do - let!(:bva_task) { create(:bva_dispatch_task, :in_progress, parent: root_task, appeal: appeal) } - let(:ama_task) { create(:ama_task, parent: root_task, appeal: appeal) } + let!(:bva_task) { create(:bva_dispatch_task, :in_progress, parent: root_task) } + let(:ama_task) { create(:ama_task, parent: root_task) } it { is_expected.to be_falsey } end context "dispatch task is complete" do - let!(:bva_task) { create(:bva_dispatch_task, :completed, parent: root_task, appeal: appeal) } + let!(:bva_task) { create(:bva_dispatch_task, :completed, parent: root_task) } context "sibling task created before dispatch task completed" do - let(:ama_task) { create(:ama_task, created_at: bva_task.closed_at - 1, parent: root_task, appeal: appeal) } + let(:ama_task) { create(:ama_task, created_at: bva_task.closed_at - 1, parent: root_task) } it { is_expected.to be_falsey } end context "sibling task created after dispatch task completed" do - let(:ama_task) { create(:ama_task, created_at: bva_task.closed_at + 1, parent: root_task, appeal: appeal) } + let(:ama_task) { create(:ama_task, created_at: bva_task.closed_at + 1, parent: root_task) } it { is_expected.to be_truthy } end @@ -117,7 +117,7 @@ end 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!(:completed_children) { create_list(:task, 3, :completed, type: Task.name, parent: task) } it "should not change the task's status" do status_before = task.status @@ -127,7 +127,7 @@ end 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(:completed_children) { create_list(:task, 3, :completed, type: Task.name, parent: task) } let!(:child) { completed_children.last } it "should change task's status to assigned" do @@ -184,7 +184,7 @@ end 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!(:completed_children) { create_list(:task, 3, :completed, type: Task.name, parent: task) } it "should not update any attribute of the task" do task_status = task.status @@ -194,7 +194,7 @@ end 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(:completed_children) { create_list(:task, 3, :completed, type: Task.name, parent: task) } let!(:child) { completed_children.last } it "should update the task" do @@ -204,7 +204,7 @@ end context "when child task has a different type than parent" do - let!(:child) { create(:quality_review_task, :completed, parent_id: task.id) } + let!(:child) { create(:quality_review_task, :completed, parent: task) } it "sets the status of the parent to assigned" do subject @@ -242,7 +242,7 @@ end context "when there is an attorney_case_review" do - let!(:child) { create(:task, type: Task.name, appeal: task.appeal, parent_id: task.id) } + let!(:child) { create(:task, type: Task.name, appeal: task.appeal, parent: task) } let!(:attorney_case_reviews) do create(:attorney_case_review, task_id: child.id, attorney: create(:user, full_name: "Bob Smith")) end @@ -284,7 +284,7 @@ end context "when there is a sub task" do - let!(:child) { create(:task, type: Task.name, appeal: task.appeal, parent_id: task.id) } + let!(:child) { create(:task, type: Task.name, appeal: task.appeal, parent: task) } let!(:attorney_case_reviews) do [ create(:attorney_case_review, task_id: child.id, created_at: 1.day.ago), @@ -322,8 +322,8 @@ context "when sub-sub-sub...task has a root task" do let(:root_task) { create(:root_task) } let(:task) do - t = create(:ama_task, parent_id: root_task.id) - 5.times { t = create(:ama_task, parent_id: t.id) } + t = create(:ama_task, parent: root_task) + 5.times { t = create(:ama_task, parent: t) } Task.last end @@ -335,7 +335,7 @@ context "when sub-sub-sub...task does not have a root task" do let(:task) do t = create(:ama_task) - 5.times { t = create(:ama_task, parent_id: t.id) } + 5.times { t = create(:ama_task, parent: t) } Task.last end @@ -803,8 +803,8 @@ describe ".reassign" do let(:org) { Organization.find(create(:organization).id) } let(:root_task) { RootTask.find(create(:root_task).id) } - let(:org_task) { create(:ama_task, parent_id: root_task.id, assigned_to: org) } - let(:task) { create(:ama_task, parent_id: org_task.id) } + let(:org_task) { create(:ama_task, parent: root_task, assigned_to: org) } + let(:task) { create(:ama_task, parent: org_task) } let(:old_assignee) { task.assigned_to } let(:new_assignee) { create(:user) } let(:params) do @@ -835,10 +835,10 @@ context "When old assignee reassigns task with several child tasks to a new user" do let(:task_type) { :ama_task } let(:closed_children_count) { 2 } - let!(:completed_children) { create_list(task_type, closed_children_count / 2, :completed, parent_id: task.id) } - let!(:cancelled_children) { create_list(task_type, closed_children_count / 2, :cancelled, parent_id: task.id) } + let!(:completed_children) { create_list(task_type, closed_children_count / 2, :completed, parent: task) } + let!(:cancelled_children) { create_list(task_type, closed_children_count / 2, :cancelled, parent: task) } let(:incomplete_children_count) { 2 } - let!(:incomplete_children) { create_list(task_type, incomplete_children_count, parent_id: task.id) } + let!(:incomplete_children) { create_list(task_type, incomplete_children_count, parent: task) } before { task.on_hold! } @@ -863,6 +863,7 @@ let(:task_type) { :timed_hold_task } it "children timer tasks are adopted by new task and not cancelled" do + task.reload expect { subject }.to_not raise_error expect(task.status).to eq(Constants.TASK_STATUSES.cancelled) diff --git a/spec/models/tasks/colocated_task_spec.rb b/spec/models/tasks/colocated_task_spec.rb index da4ccdea98a..6962c888941 100644 --- a/spec/models/tasks/colocated_task_spec.rb +++ b/spec/models/tasks/colocated_task_spec.rb @@ -374,12 +374,11 @@ let(:colocated_user) { create(:user) } let(:colocated_task) do # We expect all ColocatedTasks that are assigned to individuals to have parent tasks assigned to the organization. - org_task = create(:colocated_task, assigned_by: attorney) + org_task = create(:colocated_task, appeal: appeal_1, assigned_by: attorney) create( :colocated_task, assigned_by: attorney, assigned_to: colocated_user, - appeal: appeal_1, parent: org_task ) end diff --git a/spec/workflows/bulk_task_reassignment_spec.rb b/spec/workflows/bulk_task_reassignment_spec.rb index 18261a8b939..deeeca96953 100644 --- a/spec/workflows/bulk_task_reassignment_spec.rb +++ b/spec/workflows/bulk_task_reassignment_spec.rb @@ -85,7 +85,7 @@ let(:task_type) { :ama_judge_task } context "with open children" do - let(:child_tasks) { tasks.map { |task| create(:task, parent_id: task.id) } } + let(:child_tasks) { tasks.map { |task| create(:task, parent: task) } } it "fails and warns the caller of open children of JudgeAssignTasks" do bad_parent_output = child_tasks.map(&:id).sort.join(", ") @@ -116,8 +116,8 @@ let(:task_type) { :ama_judge_decision_review_task } context "with no open children" do - let(:child_tasks) { tasks.first(2).map { |task| create(:task, parent_id: task.id) } } - let!(:child_atty_tasks) { tasks.last(2).map { |task| create(:ama_attorney_task, parent_id: task.id) } } + let(:child_tasks) { tasks.first(2).map { |task| create(:task, parent: task) } } + let!(:child_atty_tasks) { tasks.last(2).map { |task| create(:ama_attorney_task, parent: task) } } it "fails and warns the caller of open children of JudgeAssignTasks" do bad_parent_output = child_tasks.map(&:parent_id).sort.join(", ") @@ -129,7 +129,7 @@ context "with children attorney tasks (and assignee attorney is being made inactive)" do let(:attorney) { create(:user) } let!(:child_tasks) do - tasks.map { |task| create(:ama_attorney_task, :completed, parent_id: task.id, assigned_to: attorney) } + tasks.map { |task| create(:ama_attorney_task, :completed, parent: task, assigned_to: attorney) } end context "but no judge team for the attorney" do @@ -342,7 +342,7 @@ context "with children attorney tasks" do let(:attorney) { create(:user) } let!(:child_tasks) do - tasks.map { |task| create(:ama_attorney_task, :completed, parent_id: task.id, assigned_to: attorney) } + tasks.map { |task| create(:ama_attorney_task, :completed, parent: task, assigned_to: attorney) } end let!(:judge_team) { JudgeTeam.create_for_judge(create(:user)) } diff --git a/spec/workflows/fetch_documents_for_reader_spec.rb b/spec/workflows/fetch_documents_for_reader_spec.rb index 5da707c9a6d..4c1d14defbd 100644 --- a/spec/workflows/fetch_documents_for_reader_spec.rb +++ b/spec/workflows/fetch_documents_for_reader_spec.rb @@ -69,7 +69,7 @@ end let!(:task) do create( - :colocated_task, + :ama_colocated_task, assigned_to: create(:user), assigned_by: user, appeal: appeal From bd3f312cc48741ed5f24c4aeb55a9c72582f2831 Mon Sep 17 00:00:00 2001 From: yoomlam Date: Thu, 12 Mar 2020 15:31:36 -0500 Subject: [PATCH 4/4] address CodeClimate complaints --- spec/feature/queue/ama_queue_spec.rb | 2 +- spec/feature/withdrawn_request_issues_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/feature/queue/ama_queue_spec.rb b/spec/feature/queue/ama_queue_spec.rb index cb9175c2faf..18ef0b4c3e5 100644 --- a/spec/feature/queue/ama_queue_spec.rb +++ b/spec/feature/queue/ama_queue_spec.rb @@ -119,7 +119,7 @@ def valid_document_id :in_progress, assigned_to: attorney_user, assigned_by: judge_user, - parent: parent_task, + parent: parent_task ), create( :ama_attorney_task, diff --git a/spec/feature/withdrawn_request_issues_spec.rb b/spec/feature/withdrawn_request_issues_spec.rb index ead4a74153a..9ece83e1b8e 100644 --- a/spec/feature/withdrawn_request_issues_spec.rb +++ b/spec/feature/withdrawn_request_issues_spec.rb @@ -79,7 +79,7 @@ def create_ama_attorney_task :in_progress, assigned_to: attorney, assigned_by: judge, - parent: parent_task, + parent: parent_task ) end