diff --git a/app/services/external_api/pexip_service.rb b/app/services/external_api/pexip_service.rb index 52fdfb6f208..cefa1c5ce1b 100644 --- a/app/services/external_api/pexip_service.rb +++ b/app/services/external_api/pexip_service.rb @@ -40,10 +40,10 @@ def create_conference(virtual_hearing) ExternalApi::PexipService::CreateResponse.new(resp) end - def delete_conference(conference_id:) - return if conference_id.nil? + def delete_conference(virtual_hearing) + return if virtual_hearing.conference_id.nil? - delete_endpoint = "#{CONFERENCES_ENDPOINT}#{conference_id}/" + delete_endpoint = "#{CONFERENCES_ENDPOINT}#{virtual_hearing.conference_id}/" resp = send_pexip_request(delete_endpoint, :delete) return lack_of_connectivity_response if resp.nil? diff --git a/spec/services/external_api/pexip_service_spec.rb b/spec/services/external_api/pexip_service_spec.rb index 62ef67c4100..43c9cacf4c7 100644 --- a/spec/services/external_api/pexip_service_spec.rb +++ b/spec/services/external_api/pexip_service_spec.rb @@ -93,9 +93,11 @@ end describe "#delete_conference" do - let(:conference_id) { "123" } - subject { pexip_service.delete_conference(conference_id: conference_id) } + let(:virtual_hearing) do + create(:virtual_hearing, conference_id: "123") + end + subject { pexip_service.delete_conference(virtual_hearing) } let(:success_del_resp) { HTTPI::Response.new(204, {}, {}) } let(:error_del_resp) { HTTPI::Response.new(404, {}, {}) } @@ -105,12 +107,12 @@ end it "passed correct arguments to #send_pexip_request" do - expect(pexip_service).to receive(:send_pexip_request).with("#{endpoint}#{conference_id}/", :delete) + expect(pexip_service).to receive(:send_pexip_request).with("#{endpoint}123/", :delete) subject end it "success response" do - allow(pexip_service).to receive(:send_pexip_request).with("#{endpoint}#{conference_id}/", :delete) + allow(pexip_service).to receive(:send_pexip_request).with("#{endpoint}123/", :delete) .and_return(success_del_resp) expect(subject.code).to eq(204) @@ -119,7 +121,7 @@ end it "error response" do - allow(pexip_service).to receive(:send_pexip_request).with("#{endpoint}#{conference_id}/", :delete) + allow(pexip_service).to receive(:send_pexip_request).with("#{endpoint}123/", :delete) .and_return(error_del_resp) expect(subject.code).to eq(404)