Skip to content

Commit

Permalink
Remove created_by constraint (#23354)
Browse files Browse the repository at this point in the history
* Remove created_by constraint

* Add automated test coverage

* Fix broken test

---------

Co-authored-by: Matthew Thornton <ThorntonMatthew@users.noreply.github.com>
  • Loading branch information
ThorntonMatthew and ThorntonMatthew authored Oct 25, 2024
1 parent 9a2c9d3 commit 8391ace
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/hearing_day.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion spec/jobs/virtual_hearings/create_conference_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions spec/models/hearing_day_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8391ace

Please sign in to comment.