Skip to content
Snippets Groups Projects
Unverified Commit 128feee1 authored by Hadi Cheaito's avatar Hadi Cheaito Committed by GitHub
Browse files

Pre-upload presentation backend + rpsec testing (#3526)

* Pre-upload presentation backend + rpsec testing

* CR changes

* cleaning
parent ebe9bc56
Branches
Tags
No related merge requests found
......@@ -10,7 +10,9 @@ module Api
# Returns: { data: Array[serializable objects] , errors: Array[String] }
# Does: Starts the Room meeting and joins in the meeting starter.
def start
MeetingStarter.new(room: @room, logout_url: request.referer).call
presentation_url = (url_for(@room.presentation).gsub('&', '%26') if @room.presentation.attached?)
MeetingStarter.new(room: @room, logout_url: request.referer, presentation_url:).call
render_json data: {
join_url: BigBlueButtonApi.new.join_meeting(room: @room, name: current_user.name, role: 'Moderator')
......
......@@ -13,8 +13,14 @@ class BigBlueButtonApi
end
# Start a meeting for a specific room and returns the join URL.
def start_meeting(room:, options: {})
bbb_server.create_meeting room.name, room.meeting_id, options
def start_meeting(room:, options: {}, presentation_url: nil)
if presentation_url.present?
modules = BigBlueButton::BigBlueButtonModules.new
modules.add_presentation(:url, presentation_url)
bbb_server.create_meeting(room.name, room.meeting_id, options, modules)
else
bbb_server.create_meeting(room.name, room.meeting_id, options)
end
end
def join_meeting(room:, name:, role:)
......
# frozen_string_literal: true
class MeetingStarter
def initialize(room:, logout_url:)
def initialize(room:, logout_url:, presentation_url:)
@room = room
@logout_url = logout_url
@presentation_url = presentation_url
end
def call
......@@ -14,7 +15,7 @@ class MeetingStarter
retries = 0
begin
BigBlueButtonApi.new.start_meeting room: @room, options: options
BigBlueButtonApi.new.start_meeting room: @room, options: options, presentation_url: @presentation_url
ActionCable.server.broadcast "#{@room.friendly_id}_rooms_channel", 'started'
rescue BigBlueButton::BigBlueButtonException => e
......
......@@ -22,8 +22,20 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
it 'makes a call to the MeetingStarter service with the right values' do
logout = 'http://example.com'
request.env['HTTP_REFERER'] = logout
presentation_url = nil
expect(MeetingStarter).to receive(:new).with(room:, logout_url: logout)
expect(MeetingStarter).to receive(:new).with(room:, logout_url: logout, presentation_url:)
post :start, params: { friendly_id: room.friendly_id }
end
it 'makes a call to the MeetingStarter service with the right values and presentation attached to room' do
room = create(:room, user:, presentation: fixture_file_upload(file_fixture('default-avatar.png'), 'image/png'))
logout = 'http://example.com'
request.env['HTTP_REFERER'] = logout
presentation_url = Rails.application.routes.url_helpers.rails_blob_url(room.presentation, host: 'test.host')
expect(MeetingStarter).to receive(:new).with(room:, logout_url: logout, presentation_url:)
post :start, params: { friendly_id: room.friendly_id }
end
......
......@@ -94,6 +94,16 @@ RSpec.describe Api::V1::RoomsController, type: :controller do
end
end
describe '#update' do
it 'updates the presentation' do
room = create(:room, presentation: fixture_file_upload(file_fixture('default-avatar.png'), 'image/png'))
patch :update,
params: { friendly_id: room.friendly_id,
presentation: { presentation: fixture_file_upload(file_fixture('default-avatar.png'), 'image/png') } }
expect(room.reload.presentation).to be_attached
end
end
describe '#recordings' do
it 'returns recordings belonging to the room' do
room1 = create(:room, user:, friendly_id: 'friendly_id_1')
......
......@@ -4,7 +4,8 @@ require 'rails_helper'
describe MeetingStarter, type: :service do
let(:room) { create(:room) }
let(:service) { described_class.new(room:, logout_url: 'http://example.com') }
let(:presentation_url) { 'http://www.samplepdf.com/sample.pdf' }
let(:service) { described_class.new(room:, logout_url: 'http://example.com', presentation_url:) }
let(:options) do
{
logoutURL: 'http://example.com',
......@@ -17,7 +18,7 @@ describe MeetingStarter, type: :service do
it 'calls BigBlueButtonApi with the right params' do
expect_any_instance_of(BigBlueButtonApi)
.to receive(:start_meeting)
.with(room:, options:)
.with(room:, options:, presentation_url:)
service.call
end
......@@ -29,7 +30,7 @@ describe MeetingStarter, type: :service do
expect_any_instance_of(BigBlueButtonApi)
.to receive(:start_meeting)
.with(room:, options: { test: 'test' })
.with(room:, options: { test: 'test' }, presentation_url:)
service.call
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment