Skip to content

Commit

Permalink
Fix specs and some controllers
Browse files Browse the repository at this point in the history
- Meetings controller
- Recordings controller
- Locales and specs for them
- Spec for BigbluebuttonRecordingsForRoomWorker
  • Loading branch information
wpramio committed Jul 2, 2021
1 parent df9c0b9 commit 60e7dc1
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion app/controllers/bigbluebutton/meetings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def destroy
}
end
else
flash[:error] = t('bigbluebutton_rails.meetings.notice.destroy.error_destroy')
flash[:error] = t('bigbluebutton_rails.meetings.notice.destroy.error')
redirect_to_using_params_or_back(request.referer)
end
else
Expand Down
20 changes: 5 additions & 15 deletions app/controllers/bigbluebutton/recordings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,14 @@ def update
end

def destroy
error = false
begin
@recording.destroy
message = t('bigbluebutton_rails.recordings.notice.destroy.success')
rescue BigBlueButton::BigBlueButtonException => e
error = true
message = t('bigbluebutton_rails.recordings.notice.destroy.success_with_bbb_error')
if @recording.destroy
flash[:success] = t('bigbluebutton_rails.recordings.notice.destroy.success')
else
flash[:error] = t('bigbluebutton_rails.recordings.notice.destroy.error')
end

respond_with do |format|
format.html {
if error
flash[:error] = message
redirect_to_using_params bigbluebutton_recordings_url
else
redirect_to_using_params bigbluebutton_recordings_url, :notice => message
end
}
format.html { redirect_to_using_params bigbluebutton_recordings_url }
end
end

Expand Down
4 changes: 3 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ en:
failure: "It was not possible to update your meeting record."
destroy:
success_with_bbb_error: "The record was successfully destroyed but it wasn't deleted from the videoconference server (\"%{error}\")"
error_destroy: "This record could not be deleted"
error: "This record could not be deleted"
running:
not_ended: "This record can not be deleted because the meeting is still running"
metadata:
Expand Down Expand Up @@ -126,6 +126,7 @@ en:
destroy:
success: "Recording destroyed!"
success_with_bbb_error: "The recording was successfully destroyed but it wasn't deleted from the webconference server."
error: "This recording could not be deleted."
publish:
success: "Recording published!"
unpublish:
Expand Down Expand Up @@ -155,6 +156,7 @@ en:
destroy:
success: "Room destroyed."
success_with_bbb_error: "The room was successfully destroyed but the meeting wasn't ended in the webconference server."
error: "This room could not be deleted."
end:
not_running: "The meeting could not be ended because it is not running."
success: "The meeting was successfully ended."
Expand Down
4 changes: 3 additions & 1 deletion config/locales/pt-br.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pt-br:
failure: "Não foi possível atualizar seu registro de reunião."
destroy:
success_with_bbb_error: "O registro foi destruído com sucesso mas não foi removido do servidor de videoconferência (\"%{error}\")"
error_destroy: "Não foi possível deletar este registro."
error: "Não foi possível deletar este registro."
running:
not_ended: "Este registro não pode ser deletado pois a reunião ainda está acontecendo."
metadata:
Expand Down Expand Up @@ -109,6 +109,7 @@ pt-br:
destroy:
success: "Gravação destruida!"
success_with_bbb_error: "A gravação foi destruída com sucesso mas não foi removida do servidor de webconferência."
error: "Não foi possível deletar esta gravação."
publish:
success: "Gravação publicada!"
unpublish:
Expand Down Expand Up @@ -138,6 +139,7 @@ pt-br:
destroy:
success: "Reunião destruída!"
success_with_bbb_error: "A sala foi destruída com sucesso mas a reunião não foi finalizada no servidor de webconferência."
error: "Não foi possível deletar esta sala."
end:
not_running: "A reunião não pôde ser finalizada pois não está em andamento."
success: "A reunião foi finalizada com sucesso."
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/bigbluebutton/meetings_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
it("should not decrease meetings count") { }
it { should redirect_to '/any' }
it { should set_the_flash.to(I18n.t('bigbluebutton_rails.meetings.notice.destroy.error_destroy')) }
it { should set_the_flash.to(I18n.t('bigbluebutton_rails.meetings.notice.destroy.error')) }
end
end
context "when meeting has recordings" do
Expand Down Expand Up @@ -67,7 +67,7 @@
}
it("should not decrease Recordings count") { }
it { should redirect_to '/any' }
it { should set_the_flash.to(I18n.t('bigbluebutton_rails.meetings.notice.destroy.error_destroy')) }
it { should set_the_flash.to(I18n.t('bigbluebutton_rails.meetings.notice.destroy.error')) }
end
end
end
Expand Down
12 changes: 9 additions & 3 deletions spec/controllers/bigbluebutton/recordings_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@
}
it { should respond_with(:redirect) }
it { should redirect_to bigbluebutton_recordings_url }
it { should set_the_flash.to(I18n.t('bigbluebutton_rails.recordings.notice.destroy.success')) }
it {
msg = I18n.t('bigbluebutton_rails.recordings.notice.destroy.success')
should set_the_flash.to(msg)
}
end

context "on failure" do
Expand All @@ -171,7 +174,7 @@
it { should respond_with(:redirect) }
it { should redirect_to bigbluebutton_recordings_url }
it {
msg = I18n.t('bigbluebutton_rails.recordings.notice.destroy.success_with_bbb_error')
msg = I18n.t('bigbluebutton_rails.recordings.notice.destroy.error')
should set_the_flash.to(msg)
}
end
Expand Down Expand Up @@ -207,7 +210,10 @@
}
it { should respond_with(:redirect) }
it { should redirect_to bigbluebutton_recordings_url }
it { should set_the_flash.to(I18n.t('bigbluebutton_rails.recordings.notice.destroy.success')) }
it {
msg = I18n.t('bigbluebutton_rails.recordings.notice.destroy.error')
should set_the_flash.to(msg)
}
end

context "doesn't override @recording" do
Expand Down
5 changes: 3 additions & 2 deletions spec/workers/bigbluebutton_recordings_for_room_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@
end

context "if there are still tries left" do
let(:tries_left) { 7 }
before {
BigbluebuttonRoom.stub(:find).and_return(room)
room.stub(:fetch_recordings)

intervals = BigbluebuttonRails.configuration.recording_sync_for_room_intervals
wait = intervals[intervals.length - 6]
wait = intervals[intervals.length - tries_left]
expect(Resque).to receive(:enqueue_in)
.with(wait, ::BigbluebuttonRecordingsForRoomWorker, room.id, 6)
.once
}
it { BigbluebuttonRecordingsForRoomWorker.perform(room.id, 7) }
it { BigbluebuttonRecordingsForRoomWorker.perform(room.id, tries_left) }
end

context "if there are no more tries left" do
Expand Down

0 comments on commit 60e7dc1

Please sign in to comment.