Skip to content

Commit

Permalink
Allow a meeting to be removed when its recording is not been found
Browse files Browse the repository at this point in the history
  • Loading branch information
mktn87 committed Oct 7, 2021
1 parent fcd5eec commit 32f8180
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ coverage/
rails_best_practices_output.html
bot.log
.bundle/
.byebug_history
8 changes: 5 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
bigbluebutton_rails (3.2.0)
bigbluebutton_rails (3.3.1)
activerecord-import (~> 1.0)
bigbluebutton-api-ruby (~> 1.6)
browser (~> 0.8.0)
Expand Down Expand Up @@ -134,7 +134,7 @@ GEM
mime-types (1.25.1)
mini_portile (0.6.0)
minitest (5.4.0)
mono_logger (1.1.0)
mono_logger (1.1.1)
multi_json (1.10.1)
multi_test (0.1.1)
mysql2 (0.3.18)
Expand Down Expand Up @@ -196,6 +196,7 @@ GEM
redis (~> 3.0)
resque (~> 1.25)
rufus-scheduler (~> 2.0)
rexml (3.2.5)
rspec-activemodel-mocks (1.0.1)
activemodel (>= 3.0)
activesupport (>= 3.0)
Expand Down Expand Up @@ -274,7 +275,8 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
webrobots (0.1.1)
xml-simple (1.1.5)
xml-simple (1.1.9)
rexml
xpath (2.0.0)
nokogiri (~> 1.3)

Expand Down
13 changes: 13 additions & 0 deletions app/models/bigbluebutton_recording.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,21 @@ class BigbluebuttonRecording < ActiveRecord::Base

serialize :recording_users, Array

DELETE_STATUS = {
notFound: 'notFound'
}

STATES = {
processing: 'processing',
processed: 'processed',
published: 'published',
unpublished: 'unpublished'
}

def self.delete_status
DELETE_STATUS
end

def to_param
self.recordid
end
Expand Down Expand Up @@ -75,6 +83,11 @@ def delete_from_server!
begin
self.server.send_delete_recordings(self.recordid)
rescue BigBlueButton::BigBlueButtonException => e
if e.key == DELETE_STATUS[:notFound]
logger.info "Recording #{id} not found on server."
return true
end

logger.error "Could not delete the recording #{self.id} from the server. API error: #{e}"
return false
end
Expand Down
47 changes: 37 additions & 10 deletions spec/models/bigbluebutton_meeting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,53 @@
before do
expect(BigbluebuttonMeeting.where(id: meeting.id).count).to eq(1)
expect(BigbluebuttonRecording.where(meeting_id: meeting.id).count).to eq(1)
BigbluebuttonServer.any_instance.stub(:send_delete_recordings).and_return(true)
BigbluebuttonServer.any_instance.stub(:send_delete_recordings).and_return({some: :response})
end

it "should destroy the meeting and the associated recording" do
meeting.destroy
expect(BigbluebuttonMeeting.where(id: meeting.id).count).to eq(0)
expect(BigbluebuttonRecording.where(meeting_id: meeting.id).count).to eq(0)
end

context "when the delete recording fails with notFound" do
let(:exception) do
e = BigBlueButton::BigBlueButtonException.new("Some mesage")
e.key = BigbluebuttonRecording.delete_status[:notFound]
e
end
before do
expect(BigbluebuttonMeeting.where(id: meeting.id).count).to eq(1)
expect(BigbluebuttonRecording.where(meeting_id: meeting.id).count).to eq(1)

BigbluebuttonServer.any_instance.stub(:send_delete_recordings).and_raise(exception)
end
it "should not destroy the meeting nor the associated recording" do
meeting.destroy
expect(BigbluebuttonMeeting.where(id: meeting.id).count).to eq(0)
expect(BigbluebuttonRecording.where(meeting_id: meeting.id).count).to eq(0)
end
end
end

context "when the meeting fails to be destroyed" do
before do
expect(BigbluebuttonMeeting.where(id: meeting.id).count).to eq(1)
expect(BigbluebuttonRecording.where(meeting_id: meeting.id).count).to eq(1)
BigbluebuttonServer.any_instance.stub(:send_delete_recordings).and_return(false)
end
it "should not destroy the meeting nor the associated recording" do
meeting.destroy
expect(BigbluebuttonMeeting.where(id: meeting.id).count).to eq(1)
expect(BigbluebuttonRecording.where(meeting_id: meeting.id).count).to eq(1)
context "when deleting recording fails with an exception" do
let(:exception) do
e = BigBlueButton::BigBlueButtonException.new("Some mesage")
e
end
before do
expect(BigbluebuttonMeeting.where(id: meeting.id).count).to eq(1)
expect(BigbluebuttonRecording.where(meeting_id: meeting.id).count).to eq(1)
expect(exception.key != BigbluebuttonRecording.delete_status[:notFound])

BigbluebuttonServer.any_instance.stub(:send_delete_recordings).and_raise(exception)
end
it "should not destroy the meeting nor the associated recording" do
meeting.destroy
expect(BigbluebuttonMeeting.where(id: meeting.id).count).to eq(1)
expect(BigbluebuttonRecording.where(meeting_id: meeting.id).count).to eq(1)
end
end
end
end
Expand Down

0 comments on commit 32f8180

Please sign in to comment.