GRN2-180: First stages of refactoring code for v2.4 (#748)

* Email rescues and authenticator concern

* Application controller and helper clean up

* Moved controller code out of helpers

* More helper and email clean up

* Cleaned up remaining helpers and create omniauth_options

* Controller code clean up

* restructured views structure

* Restructured role code

* Restructured profile and code clean up

* Master merge

* Added bbb server concern to deal with bbb calls

* Bug fixes and changes after changes

* rspec

* More rubocop fixes
This commit is contained in:
farhatahmad
2019-08-19 11:28:48 -04:00
committed by farhatahmad
parent 194b5ddfa0
commit fd6077696d
76 changed files with 1187 additions and 1430 deletions

View File

@ -0,0 +1,88 @@
# 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'
describe BbbServer do
include BbbServer
let(:bbb_server) { BigBlueButton::BigBlueButtonApi.new("http://bbb.example.com/bigbluebutton/api", "secret", "0.8") }
before do
@user = create(:user)
@room = @user.main_room
end
context "#running?" do
it "should return false when not running" do
expect(room_running?(@room.bbb_id)).to be false
end
it "should return true when running" do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:is_meeting_running?).and_return(true)
expect(room_running?(@room.bbb_id)).to be true
end
end
context "#start_session" do
it "should update latest session info" do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:create_meeting).and_return(
messageKey: ""
)
expect do
start_session(@room)
end.to change { @room.sessions }.by(1)
expect(@room.last_session).not_to be nil
end
end
context "#join_path" do
it "should return correct join URL for user" do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:get_meeting_info).and_return(
attendeePW: @room.attendee_pw
)
endpoint = Rails.configuration.bigbluebutton_endpoint
secret = Rails.configuration.bigbluebutton_secret
fullname = "fullName=Example"
join_via_html5 = "&join_via_html5=true"
meeting_id = "&meetingID=#{@room.bbb_id}"
password = "&password=#{@room.attendee_pw}"
query = fullname + join_via_html5 + meeting_id + password
checksum_string = "join#{query + secret}"
checksum = OpenSSL::Digest.digest('sha1', checksum_string).unpack1("H*")
expect(join_path(@room, "Example")).to eql("#{endpoint}join?#{query}&checksum=#{checksum}")
end
end
context "#recordings" do
it "deletes the recording" do
allow_any_instance_of(BigBlueButton::BigBlueButtonApi).to receive(:delete_recordings).and_return(
returncode: true, deleted: true
)
expect(delete_recording(Faker::IDNumber.valid))
.to contain_exactly([:returncode, true], [:deleted, true])
end
end
end

View File

@ -19,13 +19,15 @@
require "rails_helper"
require 'bigbluebutton_api'
shared_examples_for "recorder" do
let(:controller) { described_class } # the class that includes the concern
describe Recorder do
include Recorder
include BbbServer
let(:bbb_server) { BigBlueButton::BigBlueButtonApi.new("http://bbb.example.com/bigbluebutton/api", "secret", "0.8") }
before do
@user = create(:user)
@room = @user.main_room
allow_any_instance_of(Room).to receive(:owner).and_return(@user)
end
@ -44,7 +46,7 @@ shared_examples_for "recorder" do
]
)
expect(recordings(@room.bbb_id, @room.owner.provider)).to contain_exactly(
expect(recordings(@room.bbb_id)).to contain_exactly(
name: "Example",
playbacks:
[
@ -118,7 +120,7 @@ shared_examples_for "recorder" do
]
)
expect(all_recordings(@user.rooms.pluck(:bbb_id), @user.provider, search: "Exam", column: "name",
expect(all_recordings(@user.rooms.pluck(:bbb_id), search: "Exam", column: "name",
direction: "desc")).to eq(
[
{
@ -219,7 +221,7 @@ shared_examples_for "recorder" do
end
it "should filter recordings on name" do
expect(recordings(@room.bbb_id, @room.owner.provider, search: "Exam")).to contain_exactly(
expect(recordings(@room.bbb_id, search: "Exam")).to contain_exactly(
{
meetingID: @room.bbb_id,
name: "aExamaaa",
@ -250,7 +252,7 @@ shared_examples_for "recorder" do
end
it "should filter recordings on participants" do
expect(recordings(@room.bbb_id, @room.owner.provider, search: "5")).to contain_exactly(
expect(recordings(@room.bbb_id, search: "5")).to contain_exactly(
meetingID: @room.bbb_id,
name: "aExamaaa",
participants: "5",
@ -267,7 +269,7 @@ shared_examples_for "recorder" do
end
it "should filter recordings on format" do
expect(recordings(@room.bbb_id, @room.owner.provider, search: "presentation")).to contain_exactly(
expect(recordings(@room.bbb_id, search: "presentation")).to contain_exactly(
{
meetingID: @room.bbb_id,
name: "test",
@ -298,7 +300,7 @@ shared_examples_for "recorder" do
end
it "should filter recordings on visibility" do
expect(recordings(@room.bbb_id, @room.owner.provider, search: "public")).to contain_exactly(
expect(recordings(@room.bbb_id, search: "public")).to contain_exactly(
{
meetingID: @room.bbb_id,
name: "test",
@ -329,7 +331,7 @@ shared_examples_for "recorder" do
end
it "should filter recordings on metadata name by default" do
expect(recordings(@room.bbb_id, @room.owner.provider, search: "metadata")).to contain_exactly(
expect(recordings(@room.bbb_id, search: "metadata")).to contain_exactly(
meetingID: @room.bbb_id,
name: "Exam",
participants: "1",
@ -385,7 +387,7 @@ shared_examples_for "recorder" do
end
it "should sort recordings on name" do
expect(recordings(@room.bbb_id, @room.owner.provider, column: "name", direction: "asc")).to eq(
expect(recordings(@room.bbb_id, column: "name", direction: "asc")).to eq(
[
{
meetingID: @room.bbb_id,
@ -421,7 +423,7 @@ shared_examples_for "recorder" do
end
it "should sort recordings on participants" do
expect(recordings(@room.bbb_id, @room.owner.provider, column: "users", direction: "desc")).to eq(
expect(recordings(@room.bbb_id, column: "users", direction: "desc")).to eq(
[
{
meetingID: @room.bbb_id,
@ -457,7 +459,7 @@ shared_examples_for "recorder" do
end
it "should sort recordings on visibility" do
expect(recordings(@room.bbb_id, @room.owner.provider, column: "visibility", direction: "desc")).to eq(
expect(recordings(@room.bbb_id, column: "visibility", direction: "desc")).to eq(
[
{
meetingID: @room.bbb_id,
@ -493,7 +495,7 @@ shared_examples_for "recorder" do
end
it "should sort recordings on length" do
expect(recordings(@room.bbb_id, @room.owner.provider, column: "length", direction: "asc")).to eq(
expect(recordings(@room.bbb_id, column: "length", direction: "asc")).to eq(
[
{
meetingID: @room.bbb_id,
@ -529,7 +531,7 @@ shared_examples_for "recorder" do
end
it "should sort recordings on format" do
expect(recordings(@room.bbb_id, @room.owner.provider, column: "formats", direction: "desc")).to eq(
expect(recordings(@room.bbb_id, column: "formats", direction: "desc")).to eq(
[
{
meetingID: @room.bbb_id,