GRN2-129: Added server recordings and refactored adminsitrator panel (#662)

* Added server recordings and refactored adminsitrator panel

* Fixed some issues

* Fixed issue with owner email search

* Fixed issue with edit user
This commit is contained in:
farhatahmad
2019-07-22 12:46:48 -04:00
committed by Jesus Federico
parent 8c63f793a5
commit a055b88eb7
38 changed files with 1088 additions and 640 deletions

View File

@ -0,0 +1,567 @@
# frozen_string_literal: true
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
#
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
#
# This program is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 3.0 of the License, or (at your option) any later
# version.
#
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
require "rails_helper"
require 'bigbluebutton_api'
shared_examples_for "recorder" do
let(:controller) { described_class } # the class that includes the concern
before do
@user = create(:user)
@room = @user.main_room
allow_any_instance_of(Room).to receive(:owner).and_return(@user)
end
it "should properly find meeting recordings" do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:get_recordings).and_return(
recordings: [
{
name: "Example",
playback: {
format:
{
type: "presentation"
}
}
}
]
)
expect(recordings(@room.bbb_id, @room.owner.provider)).to contain_exactly(
name: "Example",
playbacks:
[
{
type: "presentation"
}
]
)
end
it "gets all filtered and sorted recordings for the user" do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:get_recordings).and_return(
recordings: [
{
meetingID: @room.bbb_id,
name: "Example",
participants: "3",
playback: {
format:
{
type: "presentation"
}
},
metadata: {
"gl-listed": "true",
}
},
{
meetingID: @room.bbb_id,
name: "aExamaaa",
participants: "5",
playback: {
format:
{
type: "other"
}
},
metadata: {
"gl-listed": "false",
}
},
{
meetingID: @room.bbb_id,
name: "test",
participants: "1",
playback: {
format:
{
type: "presentation"
}
},
metadata: {
"gl-listed": "true",
}
},
{
meetingID: @room.bbb_id,
name: "Exam",
participants: "1",
playback: {
format:
{
type: "other"
}
},
metadata: {
"gl-listed": "false",
name: "z",
}
}
]
)
expect(all_recordings(@user.rooms.pluck(:bbb_id), @user.provider, search: "Exam", column: "name",
direction: "desc")).to eq(
[
{
meetingID: @room.bbb_id,
name: "Example",
participants: "3",
playbacks:
[
{
type: "presentation"
}
],
metadata: {
"gl-listed": "true",
}
},
{
meetingID: @room.bbb_id,
name: "aExamaaa",
participants: "5",
playbacks:
[
{
type: "other"
}
],
metadata: {
"gl-listed": "false",
}
}
]
)
end
context '#filtering' do
before do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:get_recordings).and_return(
recordings: [
{
meetingID: @room.bbb_id,
name: "Example",
participants: "3",
playback: {
format:
{
type: "presentation"
}
},
metadata: {
"gl-listed": "true",
}
},
{
meetingID: @room.bbb_id,
name: "aExamaaa",
participants: "5",
playback: {
format:
{
type: "other"
}
},
metadata: {
"gl-listed": "false",
}
},
{
meetingID: @room.bbb_id,
name: "test",
participants: "1",
playback: {
format:
{
type: "presentation"
}
},
metadata: {
"gl-listed": "true",
}
},
{
meetingID: @room.bbb_id,
name: "Exam",
participants: "1",
playback: {
format:
{
type: "other"
}
},
metadata: {
"gl-listed": "false",
name: "metadata",
}
}
]
)
end
it "should filter recordings on name" do
expect(recordings(@room.bbb_id, @room.owner.provider, search: "Exam")).to contain_exactly(
{
meetingID: @room.bbb_id,
name: "aExamaaa",
participants: "5",
playbacks:
[
{
type: "other"
}
],
metadata: {
"gl-listed": "false",
}
},
meetingID: @room.bbb_id,
name: "Example",
participants: "3",
playbacks:
[
{
type: "presentation"
}
],
metadata: {
"gl-listed": "true",
}
)
end
it "should filter recordings on participants" do
expect(recordings(@room.bbb_id, @room.owner.provider, search: "5")).to contain_exactly(
meetingID: @room.bbb_id,
name: "aExamaaa",
participants: "5",
playbacks:
[
{
type: "other"
}
],
metadata: {
"gl-listed": "false",
}
)
end
it "should filter recordings on format" do
expect(recordings(@room.bbb_id, @room.owner.provider, search: "presentation")).to contain_exactly(
{
meetingID: @room.bbb_id,
name: "test",
participants: "1",
playbacks:
[
{
type: "presentation"
}
],
metadata: {
"gl-listed": "true",
}
},
meetingID: @room.bbb_id,
name: "Example",
participants: "3",
playbacks:
[
{
type: "presentation"
}
],
metadata: {
"gl-listed": "true",
}
)
end
it "should filter recordings on visibility" do
expect(recordings(@room.bbb_id, @room.owner.provider, search: "public")).to contain_exactly(
{
meetingID: @room.bbb_id,
name: "test",
participants: "1",
playbacks:
[
{
type: "presentation"
}
],
metadata: {
"gl-listed": "true",
},
},
meetingID: @room.bbb_id,
name: "Example",
participants: "3",
playbacks:
[
{
type: "presentation"
}
],
metadata: {
"gl-listed": "true",
}
)
end
it "should filter recordings on metadata name by default" do
expect(recordings(@room.bbb_id, @room.owner.provider, search: "metadata")).to contain_exactly(
meetingID: @room.bbb_id,
name: "Exam",
participants: "1",
playbacks:
[
{
type: "other"
}
],
metadata: {
"gl-listed": "false",
name: "metadata",
}
)
end
end
context '#sorting' do
before do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:get_recordings).and_return(
recordings: [
{
meetingID: @room.bbb_id,
name: "Example",
participants: "3",
playback: {
format: {
type: "presentation",
length: "4"
}
},
metadata: {
"gl-listed": "true",
}
},
{
meetingID: @room.bbb_id,
name: "aExamaaa",
participants: "1",
playback: {
format: {
type: "other",
length: "3"
}
},
metadata: {
name: "Z",
"gl-listed": "false"
}
}
]
)
end
it "should sort recordings on name" do
expect(recordings(@room.bbb_id, @room.owner.provider, column: "name", direction: "asc")).to eq(
[
{
meetingID: @room.bbb_id,
name: "Example",
participants: "3",
playbacks: [
{
type: "presentation",
length: "4"
}
],
metadata: {
"gl-listed": "true",
}
},
{
meetingID: @room.bbb_id,
name: "aExamaaa",
participants: "1",
playbacks: [
{
type: "other",
length: "3"
}
],
metadata: {
name: "Z",
"gl-listed": "false"
}
}
]
)
end
it "should sort recordings on participants" do
expect(recordings(@room.bbb_id, @room.owner.provider, column: "users", direction: "desc")).to eq(
[
{
meetingID: @room.bbb_id,
name: "Example",
participants: "3",
playbacks: [
{
type: "presentation",
length: "4"
}
],
metadata: {
"gl-listed": "true",
}
},
{
meetingID: @room.bbb_id,
name: "aExamaaa",
participants: "1",
playbacks: [
{
type: "other",
length: "3"
}
],
metadata: {
name: "Z",
"gl-listed": "false"
}
}
]
)
end
it "should sort recordings on visibility" do
expect(recordings(@room.bbb_id, @room.owner.provider, column: "visibility", direction: "desc")).to eq(
[
{
meetingID: @room.bbb_id,
name: "Example",
participants: "3",
playbacks: [
{
type: "presentation",
length: "4"
}
],
metadata: {
"gl-listed": "true",
}
},
{
meetingID: @room.bbb_id,
name: "aExamaaa",
participants: "1",
playbacks: [
{
type: "other",
length: "3"
}
],
metadata: {
name: "Z",
"gl-listed": "false"
}
}
]
)
end
it "should sort recordings on length" do
expect(recordings(@room.bbb_id, @room.owner.provider, column: "length", direction: "asc")).to eq(
[
{
meetingID: @room.bbb_id,
name: "aExamaaa",
participants: "1",
playbacks: [
{
type: "other",
length: "3"
}
],
metadata: {
name: "Z",
"gl-listed": "false"
}
},
{
meetingID: @room.bbb_id,
name: "Example",
participants: "3",
playbacks: [
{
type: "presentation",
length: "4"
}
],
metadata: {
"gl-listed": "true",
}
}
]
)
end
it "should sort recordings on format" do
expect(recordings(@room.bbb_id, @room.owner.provider, column: "formats", direction: "desc")).to eq(
[
{
meetingID: @room.bbb_id,
name: "Example",
participants: "3",
playbacks: [
{
type: "presentation",
length: "4"
}
],
metadata: {
"gl-listed": "true",
}
},
{
meetingID: @room.bbb_id,
name: "aExamaaa",
participants: "1",
playbacks: [
{
type: "other",
length: "3"
}
],
metadata: {
name: "Z",
"gl-listed": "false"
}
}
]
)
end
end
end

View File

@ -52,7 +52,7 @@ describe AdminsController, type: :controller do
get :edit_user, params: { user_uid: @user.uid }
expect(response).to render_template(:index)
expect(response).to render_template(:edit_user)
end
end
@ -197,7 +197,7 @@ describe AdminsController, type: :controller do
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Branding Image")
expect(feature[:value]).to eq(fake_image_url)
expect(response).to redirect_to(admins_path)
expect(response).to redirect_to(admin_site_settings_path)
end
end
@ -214,7 +214,7 @@ describe AdminsController, type: :controller do
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Primary Color")
expect(feature[:value]).to eq(primary_color)
expect(response).to redirect_to(admins_path)
expect(response).to redirect_to(admin_site_settings_path)
end
it "changes the primary-lighten on the page" do
@ -229,7 +229,7 @@ describe AdminsController, type: :controller do
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Primary Color Lighten")
expect(feature[:value]).to eq(primary_color)
expect(response).to redirect_to(admins_path)
expect(response).to redirect_to(admin_site_settings_path)
end
it "changes the primary-darken on the page" do
@ -244,7 +244,7 @@ describe AdminsController, type: :controller do
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Primary Color Darken")
expect(feature[:value]).to eq(primary_color)
expect(response).to redirect_to(admins_path)
expect(response).to redirect_to(admin_site_settings_path)
end
end
end
@ -264,7 +264,7 @@ describe AdminsController, type: :controller do
expect(feature[:value]).to eq(Rails.configuration.registration_methods[:invite])
expect(flash[:success]).to be_present
expect(response).to redirect_to(admins_path)
expect(response).to redirect_to(admin_site_settings_path)
end
it "does not allow the user to change to invite if emails are off" do
@ -277,7 +277,7 @@ describe AdminsController, type: :controller do
post :registration_method, params: { method: "invite" }
expect(flash[:alert]).to be_present
expect(response).to redirect_to(admins_path)
expect(response).to redirect_to(admin_site_settings_path)
end
end
@ -293,7 +293,7 @@ describe AdminsController, type: :controller do
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Room Authentication")
expect(feature[:value]).to eq("true")
expect(response).to redirect_to(admins_path)
expect(response).to redirect_to(admin_site_settings_path)
end
end
@ -309,7 +309,7 @@ describe AdminsController, type: :controller do
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Room Limit")
expect(feature[:value]).to eq("5")
expect(response).to redirect_to(admins_path)
expect(response).to redirect_to(admin_site_settings_path)
end
end
end

View File

@ -28,6 +28,8 @@ def random_valid_room_params
end
describe RoomsController, type: :controller do
it_behaves_like "recorder"
include Recorder
describe "GET #show" do
before do
@user = create(:user)
@ -39,7 +41,7 @@ describe RoomsController, type: :controller do
get :show, params: { room_uid: @owner.main_room }
expect(assigns(:recordings)).to eql(@owner.main_room.recordings)
expect(assigns(:recordings)).to eql(recordings(@owner.main_room.bbb_id, @owner.provider))
expect(assigns(:is_running)).to eql(@owner.main_room.running?)
end

View File

@ -302,6 +302,7 @@ describe UsersController, type: :controller do
describe "PATCH #update" do
it "properly updates user attributes" do
user = create(:user)
@request.session[:user_id] = user.id
params = random_valid_user_params
patch :update, params: params.merge!(user_uid: user)
@ -315,6 +316,7 @@ describe UsersController, type: :controller do
it "renders #edit on unsuccessful save" do
@user = create(:user)
@request.session[:user_id] = @user.id
patch :update, params: invalid_params.merge!(user_uid: @user)
expect(response).to render_template(:edit)

View File

@ -133,420 +133,6 @@ describe Room, type: :model do
end
context "#recordings" do
it "should properly find meeting recordings" do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:get_recordings).and_return(
recordings: [
{
name: "Example",
playback: {
format:
{
type: "presentation"
}
}
}
]
)
expect(@room.recordings).to contain_exactly(
name: "Example",
playbacks:
[
{
type: "presentation"
}
]
)
end
context '#filtering' do
before do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:get_recordings).and_return(
recordings: [
{
name: "Example",
participants: "3",
playback: {
format:
{
type: "presentation"
}
},
metadata: {
"gl-listed": "true",
}
},
{
name: "aExamaaa",
participants: "5",
playback: {
format:
{
type: "other"
}
},
metadata: {
"gl-listed": "false",
}
},
{
name: "test",
participants: "1",
playback: {
format:
{
type: "presentation"
}
},
metadata: {
"gl-listed": "true",
}
},
{
name: "Exam",
participants: "1",
playback: {
format:
{
type: "other"
}
},
metadata: {
"gl-listed": "false",
name: "z",
}
}
]
)
end
it "should filter recordings on name" do
expect(@room.recordings(search: "Exam")).to contain_exactly(
{
name: "aExamaaa",
participants: "5",
playbacks:
[
{
type: "other"
}
],
metadata: {
"gl-listed": "false",
}
},
name: "Example",
participants: "3",
playbacks:
[
{
type: "presentation"
}
],
metadata: {
"gl-listed": "true",
}
)
end
it "should filter recordings on participants" do
expect(@room.recordings(search: "5")).to contain_exactly(
name: "aExamaaa",
participants: "5",
playbacks:
[
{
type: "other"
}
],
metadata: {
"gl-listed": "false",
}
)
end
it "should filter recordings on format" do
expect(@room.recordings(search: "presentation")).to contain_exactly(
{
name: "test",
participants: "1",
playbacks:
[
{
type: "presentation"
}
],
metadata: {
"gl-listed": "true",
}
},
name: "Example",
participants: "3",
playbacks:
[
{
type: "presentation"
}
],
metadata: {
"gl-listed": "true",
}
)
end
it "should filter recordings on visibility" do
expect(@room.recordings(search: "public")).to contain_exactly(
{
name: "test",
participants: "1",
playbacks:
[
{
type: "presentation"
}
],
metadata: {
"gl-listed": "true",
},
},
name: "Example",
participants: "3",
playbacks:
[
{
type: "presentation"
}
],
metadata: {
"gl-listed": "true",
}
)
end
it "should filter recordings on metadata name by default" do
expect(@room.recordings(search: "z")).to contain_exactly(
name: "Exam",
participants: "1",
playbacks:
[
{
type: "other"
}
],
metadata: {
"gl-listed": "false",
name: "z",
}
)
end
end
context '#sorting' do
before do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:get_recordings).and_return(
recordings: [
{
name: "Example",
participants: "3",
playback: {
format: {
type: "presentation",
length: "4"
}
},
metadata: {
"gl-listed": "true",
}
},
{
name: "aExamaaa",
participants: "1",
playback: {
format: {
type: "other",
length: "3"
}
},
metadata: {
name: "Z",
"gl-listed": "false"
}
}
]
)
end
it "should sort recordings on name" do
expect(@room.recordings(column: "name", direction: "asc")).to eq(
[
{
name: "Example",
participants: "3",
playbacks: [
{
type: "presentation",
length: "4"
}
],
metadata: {
"gl-listed": "true",
}
},
{
name: "aExamaaa",
participants: "1",
playbacks: [
{
type: "other",
length: "3"
}
],
metadata: {
name: "Z",
"gl-listed": "false"
}
}
]
)
end
it "should sort recordings on participants" do
expect(@room.recordings(column: "users", direction: "desc")).to eq(
[
{
name: "Example",
participants: "3",
playbacks: [
{
type: "presentation",
length: "4"
}
],
metadata: {
"gl-listed": "true",
}
},
{
name: "aExamaaa",
participants: "1",
playbacks: [
{
type: "other",
length: "3"
}
],
metadata: {
name: "Z",
"gl-listed": "false"
}
}
]
)
end
it "should sort recordings on visibility" do
expect(@room.recordings(column: "visibility", direction: "desc")).to eq(
[
{
name: "Example",
participants: "3",
playbacks: [
{
type: "presentation",
length: "4"
}
],
metadata: {
"gl-listed": "true",
}
},
{
name: "aExamaaa",
participants: "1",
playbacks: [
{
type: "other",
length: "3"
}
],
metadata: {
name: "Z",
"gl-listed": "false"
}
}
]
)
end
it "should sort recordings on length" do
expect(@room.recordings(column: "length", direction: "asc")).to eq(
[
{
name: "aExamaaa",
participants: "1",
playbacks: [
{
type: "other",
length: "3"
}
],
metadata: {
name: "Z",
"gl-listed": "false"
}
},
{
name: "Example",
participants: "3",
playbacks: [
{
type: "presentation",
length: "4"
}
],
metadata: {
"gl-listed": "true",
}
}
]
)
end
it "should sort recordings on format" do
expect(@room.recordings(column: "formats", direction: "desc")).to eq(
[
{
name: "Example",
participants: "3",
playbacks: [
{
type: "presentation",
length: "4"
}
],
metadata: {
"gl-listed": "true",
}
},
{
name: "aExamaaa",
participants: "1",
playbacks: [
{
type: "other",
length: "3"
}
],
metadata: {
name: "Z",
"gl-listed": "false"
}
}
]
)
end
end
it "deletes the recording" do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:delete_recordings).and_return(
returncode: true, deleted: true

View File

@ -173,97 +173,4 @@ describe User, type: :model do
.to raise_exception(ActiveRecord::RecordInvalid, "Validation failed: Email can't be blank")
end
end
context '#recordings' do
it "gets all filtered and sorted recordings for the user" do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:get_recordings).and_return(
recordings: [
{
name: "Example",
participants: "3",
playback: {
format:
{
type: "presentation"
}
},
metadata: {
"gl-listed": "true",
}
},
{
name: "aExamaaa",
participants: "5",
playback: {
format:
{
type: "other"
}
},
metadata: {
"gl-listed": "false",
}
},
{
name: "test",
participants: "1",
playback: {
format:
{
type: "presentation"
}
},
metadata: {
"gl-listed": "true",
}
},
{
name: "Exam",
participants: "1",
playback: {
format:
{
type: "other"
}
},
metadata: {
"gl-listed": "false",
name: "z",
}
}
]
)
expect(@user.all_recordings(search: "Exam", column: "name", direction: "desc")).to eq(
[
{
name: "Example",
participants: "3",
playbacks:
[
{
type: "presentation"
}
],
metadata: {
"gl-listed": "true",
}
},
{
name: "aExamaaa",
participants: "5",
playbacks:
[
{
type: "other"
}
],
metadata: {
"gl-listed": "false",
}
}
]
)
end
end
end