diff --git a/app/models/legacy_appeal_representative.rb b/app/models/legacy_appeal_representative.rb index 9bed942ceba..8a6e1592e6e 100644 --- a/app/models/legacy_appeal_representative.rb +++ b/app/models/legacy_appeal_representative.rb @@ -51,6 +51,7 @@ def representative_to_hash def use_representative_info_from_bgs? RequestStore.store[:application] == "queue" || RequestStore.store[:application] == "hearings" || + RequestStore.store[:application] == "hearing_schedule_job" || RequestStore.store[:application] == "idt" end diff --git a/spec/jobs/virtual_hearings/create_conference_job_spec.rb b/spec/jobs/virtual_hearings/create_conference_job_spec.rb index 8e24bdd144b..07d8e87e11f 100644 --- a/spec/jobs/virtual_hearings/create_conference_job_spec.rb +++ b/spec/jobs/virtual_hearings/create_conference_job_spec.rb @@ -214,5 +214,52 @@ ) end end + + context "for a legacy hearings" do + let(:appeal) do + create( + :legacy_appeal, + :with_veteran, + vacols_case: create(:case) + ) + end + let!(:representative) do + create( + :representative, + repfirst: "Serrif", + replast: "Gnest", + repkey: appeal.vacols_id + ) + end + let(:hearing) { create(:legacy_hearing, appeal: appeal) } + + context "when representative is different in VACOLS and VBMS" do + it "uses the representative in VBMS" do + # Sanity check that calling `LegacyAppeal#representative_name` returns the + # VACOLS value if the `RequestStore.store[:application]` isn't set + expect(appeal.representative_name).to eq("Serrif Gnest") + + expect(MailRecipient).to( + receive(:new) + .with(instance_of(Hash)) + .twice + .and_call_original + ) + expect(MailRecipient).to( + receive(:new) + .with( + hash_including( + name: FakeConstants.BGS_SERVICE.DEFAULT_POA_NAME, + title: MailRecipient::RECIPIENT_TITLES[:representative] + ) + ) + .once + .and_call_original + ) + + subject.perform_now + end + end + end end end