Added tests

This commit is contained in:
farhatahmad 2020-04-06 16:25:04 -04:00
parent 33d7fa4e1e
commit 63b6bb7407
2 changed files with 63 additions and 2 deletions

View File

@ -62,7 +62,8 @@ class RoomsController < ApplicationController
# GET /:room_uid
def show
@anyone_can_start = JSON.parse(@room[:room_settings])["anyoneCanStart"]
@room_settings = @room[:room_settings]
@anyone_can_start = room_setting_with_config("anyoneCanStart")
@room_running = room_running?(@room.bbb_id)
@shared_room = room_shared_with_user

View File

@ -275,7 +275,37 @@ describe RoomsController, type: :controller do
expect(response).to redirect_to(join_path(room, @user.name, { user_is_moderator: false }, @user.uid))
end
it "should join the room as moderator if room has the all_join_moderator setting" do
it "doesn't join the room if the room has the anyone_can_start setting but config is disabled" do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(false)
allow_any_instance_of(Setting).to receive(:get_value).and_return("disabled")
room = Room.new(name: "test")
room.room_settings = "{\"muteOnStart\":false,\"joinViaHtml5\":false,\"anyoneCanStart\":true}"
room.owner = @owner
room.save
@request.session[:user_id] = @user.id
post :join, params: { room_uid: room, join_name: @user.name }
expect(response).to render_template(:wait)
end
it "joins the room if the room doesn't have the anyone_can_start setting but config is set to enabled" do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(false)
allow_any_instance_of(Setting).to receive(:get_value).and_return("enabled")
room = Room.new(name: "test")
room.room_settings = "{\"anyoneCanStart\":false}"
room.owner = @owner
room.save
@request.session[:user_id] = @user.id
post :join, params: { room_uid: room, join_name: @user.name }
expect(response).to redirect_to(join_path(room, @user.name, { user_is_moderator: true }, @user.uid))
end
it "joins the room as moderator if room has the all_join_moderator setting" do
allow_any_instance_of(Setting).to receive(:get_value).and_return("optional")
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(true)
@ -290,6 +320,36 @@ describe RoomsController, type: :controller do
expect(response).to redirect_to(join_path(room, @user.name, { user_is_moderator: true }, @user.uid))
end
it "joins the room as moderator if room doesn't have all_join_moderator but config is set to enabled" do
allow_any_instance_of(Setting).to receive(:get_value).and_return("enabled")
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(true)
room = Room.new(name: "test")
room.room_settings = "{ }"
room.owner = @owner
room.save
@request.session[:user_id] = @user.id
post :join, params: { room_uid: room, join_name: @user.name }
expect(response).to redirect_to(join_path(room, @user.name, { user_is_moderator: true }, @user.uid))
end
it "doesn't join the room as moderator if room has the all_join_moderator setting but config is set to disabled" do
allow_any_instance_of(Setting).to receive(:get_value).and_return("disabled")
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(true)
room = Room.new(name: "test")
room.room_settings = "{\"joinModerator\":true}"
room.owner = @owner
room.save
@request.session[:user_id] = @user.id
post :join, params: { room_uid: room, join_name: @user.name }
expect(response).to redirect_to(join_path(room, @user.name, { user_is_moderator: false }, @user.uid))
end
it "should render wait if the correct access code is supplied" do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(false)