diff --git a/app/jobs/set_appeal_age_aod_job.rb b/app/jobs/set_appeal_age_aod_job.rb index e055d8f0785..bcf3ad8702b 100644 --- a/app/jobs/set_appeal_age_aod_job.rb +++ b/app/jobs/set_appeal_age_aod_job.rb @@ -2,7 +2,7 @@ # Early morning job that checks if the claimant meets the Advance-On-Docket age criteria. # If criteria is satisfied, all active appeals associated with claimant will be marked as AOD. -# This job only sets age_aod to true; it does not set it from true to false (see appeal.conditionally_set_age_aod). +# This job only sets aod_based_on_age to true; it does not set it from true to false (see appeal.conditionally_set_age_aod). class SetAppealAgeAodJob < CaseflowJob include ActionView::Helpers::DateHelper @@ -13,8 +13,7 @@ def perform appeals = non_aod_active_appeals.joins(claimants: :person).where("people.date_of_birth <= ?", 75.years.ago) detail_msg = "IDs of age-related AOD appeals: #{appeals.pluck(:id)}" - appeals.update_all(age_aod: true) - appeals.update_all(updated_at: Time.now.utc) + appeals.update_all(aod_based_on_age: true, updated_at: Time.now.utc) log_success(detail_msg) rescue StandardError => error @@ -45,8 +44,8 @@ def log_error(collector_name, err, details) private def non_aod_active_appeals - # `age_aod` is initially nil - # `age_aod` being false means that it was once true (in the case where the claimant's DOB was updated) - Appeal.active.where(age_aod: [nil, false]) + # `aod_based_on_age` is initially nil + # `aod_based_on_age` being false means that it was once true (in the case where the claimant's DOB was updated) + Appeal.active.where(aod_based_on_age: [nil, false]) end end diff --git a/app/models/appeal.rb b/app/models/appeal.rb index 5d7b58ef09b..6182fcc5747 100644 --- a/app/models/appeal.rb +++ b/app/models/appeal.rb @@ -34,7 +34,7 @@ class Appeal < DecisionReview "de_novo": "de_novo" } - after_create :conditionally_set_age_aod + after_create :conditionally_set_aod_based_on_age after_save :set_original_stream_data @@ -269,16 +269,16 @@ def regional_office_key nil end - def conditionally_set_age_aod - aod_based_on_age = claimant&.advanced_on_docket_based_on_age? - update(age_aod: aod_based_on_age) if age_aod != aod_based_on_age + def conditionally_set_aod_based_on_age + updated_aod_based_on_age = claimant&.advanced_on_docket_based_on_age? + update(aod_based_on_age: updated_aod_based_on_age) if aod_based_on_age != updated_aod_based_on_age end def advanced_on_docket? - conditionally_set_age_aod - # One of the AOD motion reasons is 'age'. Keep interrogation of any motions separate from `age_aod`, + conditionally_set_aod_based_on_age + # One of the AOD motion reasons is 'age'. Keep interrogation of any motions separate from `aod_based_on_age`, # which reflects `claimant.advanced_on_docket_based_on_age?`. - age_aod || claimant&.advanced_on_docket_motion_granted?(receipt_date) + aod_based_on_age || claimant&.advanced_on_docket_motion_granted?(receipt_date) end # Prefer aod? over aod going forward, as this function returns a boolean diff --git a/spec/jobs/set_appeal_age_aod_job_spec.rb b/spec/jobs/set_appeal_age_aod_job_spec.rb index f6347b65800..e3875bfcaf1 100644 --- a/spec/jobs/set_appeal_age_aod_job_spec.rb +++ b/spec/jobs/set_appeal_age_aod_job_spec.rb @@ -10,7 +10,7 @@ # rubocop:enable Metrics/LineLength describe "#perform" do - let(:appeal) { create(:appeal, :with_schedule_hearing_tasks) } + let(:non_aod_appeal) { create(:appeal, :with_schedule_hearing_tasks) } let(:age_aod_appeal) { create(:appeal, :with_schedule_hearing_tasks, :advanced_on_docket_due_to_age) } let(:motion_aod_appeal) { create(:appeal, :with_schedule_hearing_tasks, :advanced_on_docket_due_to_motion) } @@ -22,8 +22,8 @@ allow_any_instance_of(SlackService).to receive(:send_notification) { |_, first_arg| @slack_msg = first_arg } end - it "sets age_aod for only active appeals with a claimant that satisfies the age criteria" do - expect(appeal.active?).to eq(true) + it "sets aod_based_on_age for only active appeals with a claimant that satisfies the age criteria" do + expect(non_aod_appeal.active?).to eq(true) expect(age_aod_appeal.active?).to eq(true) expect(motion_aod_appeal.active?).to eq(true) expect(inactive_age_aod_appeal.active?).to eq(false) @@ -32,13 +32,13 @@ described_class.perform_now expect(@slack_msg).to include(success_msg) - # `age_aod` will be nil - # `age_aod` being false means that it was once true (in the case where the claimant's DOB was updated) - expect(appeal.reload.age_aod).not_to eq(true) - expect(inactive_age_aod_appeal.reload.age_aod).not_to eq(true) + # `aod_based_on_age` will be nil + # `aod_based_on_age` being false means that it was once true (in the case where the claimant's DOB was updated) + expect(non_aod_appeal.reload.aod_based_on_age).not_to eq(true) + expect(inactive_age_aod_appeal.reload.aod_based_on_age).not_to eq(true) - expect(age_aod_appeal.reload.age_aod).to eq(true) - expect(motion_aod_appeal.reload.age_aod).to eq(false) + expect(age_aod_appeal.reload.aod_based_on_age).to eq(true) + expect(motion_aod_appeal.reload.aod_based_on_age).to eq(false) end context "when the entire job fails" do diff --git a/spec/models/appeal_spec.rb b/spec/models/appeal_spec.rb index 8903b74de10..d3dfa513443 100644 --- a/spec/models/appeal_spec.rb +++ b/spec/models/appeal_spec.rb @@ -460,7 +460,7 @@ it "returns true" do expect(appeal.advanced_on_docket?).to eq(true) - expect(appeal.age_aod).to eq(true) + expect(appeal.aod_based_on_age).to eq(true) end end @@ -469,7 +469,7 @@ it "returns false" do expect(appeal.advanced_on_docket?).to eq(false) - expect(appeal.age_aod).to eq(false) + expect(appeal.aod_based_on_age).to eq(false) end end @@ -478,7 +478,7 @@ it "returns true" do expect(appeal.advanced_on_docket?).to eq(true) - expect(appeal.age_aod).to eq(false) + expect(appeal.aod_based_on_age).to eq(false) end end end