Initial commit

This commit is contained in:
Senad Uka
2020-05-31 22:38:19 +02:00
commit 858fafc3c5
1280 changed files with 65918 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
require "rails_helper"
RSpec.describe BroadcastsChannel, type: :channel do
let(:broadcast) { create(:broadcast, :with_stream, skip_create_callback: true) }
before do
stub_connection
end
it "successfully subscribes to public stream" do
subscribe token: broadcast.token
expect(subscription).to be_confirmed
expect(subscription).to have_stream_for(broadcast)
end
describe ".broadcast_stream_updates" do
it "broadcasts to the channel" do
status_content = ApplicationController.render partial: "broadcasts/broadcast_status", locals: { broadcast: broadcast }
video_content = ApplicationController.render partial: "broadcasts/video", locals: { broadcast: broadcast }
expect {
BroadcastsChannel.broadcast_stream_updates(broadcast)
}.to have_broadcasted_to(broadcast).with({
event: "broadcast_stream_update",
status: broadcast.status,
playback_url: broadcast.stream_playback_url,
status_content: status_content,
video_content: video_content,
streamer_status: broadcast.streamer_status
})
end
end
describe '#stream_recording_ready' do
it 'broadcasts to the channel with the right data' do
create_list(:broadcast_recording, 1, broadcast: broadcast)
recordings = broadcast.broadcast_recordings.paginate(page: 1)
flash_message = OpenStruct.new(notice: 'Hello world', alert: nil)
flash_content = ApplicationController.render partial: 'application/flash', locals: { flash: flash_message }
recordings_content = ApplicationController.render partial: 'broadcasts/broadcast_recordings', locals: { recordings: recordings, broadcast: broadcast }
recordings_nav_content = ApplicationController.render partial: 'broadcasts/broadcast_recording_nav', collection: recordings, as: :broadcast_recording
expect {
BroadcastsChannel.stream_recording_ready(broadcast, recordings, 'Hello world')
}.to have_broadcasted_to(broadcast).with({
event: 'stream_recording_ready',
flash_content: flash_content,
recordings_content: recordings_content,
recordings_nav_content: recordings_nav_content
})
end
end
end

View File

@@ -0,0 +1,43 @@
require "rails_helper"
RSpec.describe ProjectsChannel, type: :channel do
let(:user) { create(:user) }
let(:project) { create(:project, account: user.primary_account) }
before do
stub_connection current_user: user
end
it "successfully subscribes to project stream" do
subscribe id: project.id
expect(subscription).to be_confirmed
expect(subscription).to have_stream_for(project)
end
describe ".broadcast_video_analysis_update" do
it "broadcasts to the project channel" do
video = create(:video, project: project)
content = ApplicationController.render partial: "video_analyses/video_status_updated", locals: { video: video }
expect {
ProjectsChannel.broadcast_video_analysis_update(video)
}.to have_broadcasted_to(project).with(event: "video_status_update", content: content)
end
end
describe ".conference_recording_ready" do
it "broadcasts to the project channel" do
recording_file = Rack::Test::UploadedFile.new(Rails.root.join("spec", "fixtures", "files", "video_file.mp4"), "video/mp4")
zoom_meeting = create(:zoom_meeting, project: project, recording: recording_file)
video_url = 'http://url.to.video/video.mp4'
allow(zoom_meeting.recording).to receive(:service_url).and_return(video_url)
expect {
ProjectsChannel.conference_recording_ready(project, zoom_meeting.recording)
}.to have_broadcasted_to(project).with { |data|
expect(data['content']).to include(video_url)
expect(data['event']).to eq('conference_recording_ready')
}
end
end
end