From 8391ace23de533d4ff51179a4b43ba05a1abf803 Mon Sep 17 00:00:00 2001 From: Matthew Thornton <99351305+ThorntonMatthew@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:22:13 -0400 Subject: [PATCH] Remove created_by constraint (#23354) * Remove created_by constraint * Add automated test coverage * Fix broken test --------- Co-authored-by: Matthew Thornton --- app/models/hearing_day.rb | 2 +- .../create_conference_job_spec.rb | 5 ++- spec/models/hearing_day_spec.rb | 34 +++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/models/hearing_day.rb b/app/models/hearing_day.rb index 76df6df34b1..f20b2d367ea 100644 --- a/app/models/hearing_day.rb +++ b/app/models/hearing_day.rb @@ -293,7 +293,7 @@ def combine_time_and_date(time, timezone, date) # Method to get the associated conference link records if they exist and if not create new ones def find_or_create_conference_link! if FeatureToggle.enabled?(:pexip_conference_service) - PexipConferenceLink.find_or_create_by!(hearing_day: self, created_by: created_by) + PexipConferenceLink.find_or_create_by!(hearing_day: self) end end diff --git a/spec/jobs/virtual_hearings/create_conference_job_spec.rb b/spec/jobs/virtual_hearings/create_conference_job_spec.rb index df03c2b95fe..2d6d62d8481 100644 --- a/spec/jobs/virtual_hearings/create_conference_job_spec.rb +++ b/spec/jobs/virtual_hearings/create_conference_job_spec.rb @@ -262,7 +262,10 @@ repkey: appeal.vacols_id ) end - let(:hearing) { create(:legacy_hearing, appeal: appeal) } + let(:hearing) do + RequestStore[:current_user] = current_user + create(:legacy_hearing, appeal: appeal) + end context "when representative is different in VACOLS and VBMS" do it "uses the representative in VBMS" do diff --git a/spec/models/hearing_day_spec.rb b/spec/models/hearing_day_spec.rb index 72e7a426c4c..5ce3387c0d5 100644 --- a/spec/models/hearing_day_spec.rb +++ b/spec/models/hearing_day_spec.rb @@ -584,6 +584,40 @@ def format_begins_at_from_db(time_string, scheduled_for) end end + context "hearing day is in future, link already exists and its created_by user differs \ + from that of the hearing day's" do + let(:user_1) { User.create(css_id: "user_1", station_id: 101) } + let(:user_2) { User.create(css_id: "user_2", station_id: 101) } + + let(:hearing_day) do + create( + :hearing_day, + request_type: HearingDay::REQUEST_TYPES[:video], + scheduled_for: 1.month.from_now, + regional_office: "RO01", + created_by: user_1, + room: "1" + ) + end + + let!(:preexisting_conference_link) do + PexipConferenceLink.create!( + hearing_day: hearing_day, + created_by: user_2 + ) + end + + subject { hearing_day.conference_link } + + it "A new link is NOT created" do + subject + + expect( + ConferenceLink.where(hearing_day: hearing_day).count + ).to eq 1 + end + end + context "hearing day in the future, conference link doesnt exist" do let(:hearing_day) do RequestStore[:current_user] = User.create(css_id: "BVASCASPER1", station_id: 101)