Upstream sync

This commit is contained in:
Senad Uka
2020-08-20 06:50:51 +02:00
parent 190ff2854b
commit 41bf88e358
127 changed files with 1399 additions and 565 deletions

View File

@@ -15,14 +15,6 @@ RSpec.describe AcquiredMediaRelease do
it { is_expected.to validate_attachment_of(:contract).on(:non_native) }
end
describe "associations" do
it { is_expected.to have_many(:file_infos).dependent(:destroy) }
end
describe "nested attributes" do
it { is_expected.to accept_nested_attributes_for(:file_infos) }
end
describe "validations" do
it { is_expected.to validate_presence_of(:name) }

View File

@@ -32,7 +32,7 @@ describe AppHost do
app_domain = AppHost.new(env, "production")
expect(app_domain.domain).to eq("bigmedia.ai")
expect(app_domain.domain).to eq("mesuite.ai")
end
end
end

View File

@@ -20,6 +20,7 @@ RSpec.describe Broadcast, type: :model do
let(:broadcast) { build(:broadcast, name: "My Broadcast") }
let(:live_stream_data) { OpenStruct.new(data: OpenStruct.new(id: "stream_id", stream_key: "stream_key")) }
let(:live_stream_playback_data) { OpenStruct.new(data: OpenStruct.new(id: "playback_id")) }
let(:simulcast_data) { OpenStruct.new(data: OpenStruct.new(id: "simulcast_id")) }
it 'triggers create_mux_live_stream' do
expect(broadcast).to receive(:create_mux_live_stream)
@@ -28,14 +29,18 @@ RSpec.describe Broadcast, type: :model do
end
it 'assigns stream_id, stream_key and stream_playback_id to broadcast' do
allow(MillicastDestination).to receive(:create).and_return(OpenStruct.new(key: "123", url: "http://test.com/rtmp"))
allow_any_instance_of(MuxLiveStream).to receive(:test_mode_enabled?).and_return(false)
allow_any_instance_of(MuxRuby::LiveStreamsApi).to receive(:create_live_stream).and_return(live_stream_data)
allow_any_instance_of(MuxRuby::LiveStreamsApi).to receive(:create_live_stream_playback_id).and_return(live_stream_playback_data)
allow_any_instance_of(MuxRuby::LiveStreamsApi).to receive(:create_live_stream_simulcast_target).and_return(simulcast_data)
broadcast.save
expect(broadcast.stream_uid).to eq "stream_id"
expect(broadcast.stream_key).to eq "stream_key"
expect(broadcast.stream_playback_uid).to eq "playback_id"
expect(broadcast.simulcast_uid).to eq "simulcast_id"
end
end

View File

@@ -55,4 +55,28 @@ describe ContractTemplate do
expect(contract_template).to have_questionnaire
end
end
describe '#has_exhibit_a?' do
it 'returns true if the legal text is present' do
contract_template = build(:contract_template)
expect(contract_template).not_to have_exhibit_a
contract_template.exhibit_a_legal_text = 'Exhibit A legal text'
expect(contract_template).to have_exhibit_a
end
end
describe '#has_exhibit_b?' do
it 'returns true if the legal text is present' do
contract_template = build(:contract_template)
expect(contract_template).not_to have_exhibit_b
contract_template.exhibit_b_legal_text = 'Exhibit A legal text'
expect(contract_template).to have_exhibit_b
end
end
end

View File

@@ -5,6 +5,7 @@ RSpec.describe MuxLiveStream, type: :model do
let(:broadcast_2) { create(:broadcast, :with_stream, skip_create_callback: true, name: "My Broadcast") }
let(:live_stream_data) { OpenStruct.new(data: OpenStruct.new(id: "stream_id", stream_key: "stream_key")) }
let(:live_stream_playback_data) { OpenStruct.new(data: OpenStruct.new(id: "playback_id")) }
let(:live_stream_simulcast_data) { OpenStruct.new(data: OpenStruct.new(id: "simulcast_id")) }
it "creates live stream and live stream playback URL" do
allow_any_instance_of(MuxRuby::LiveStreamsApi).to receive(:create_live_stream).and_return(live_stream_data)
@@ -85,4 +86,51 @@ RSpec.describe MuxLiveStream, type: :model do
expect(request).to have_received(:test=).with(false)
end
end
describe "#create_simulcast" do
it "creates a simulcast for the live stream" do
allow(ENV).to receive(:[]).with("MUX_REDUCED_LATENCY_ENABLED").and_return("true")
allow(ENV).to receive(:[]).with("MUX_TEST_MODE_DISABLED").and_return("true")
request = instance_double(MuxRuby::CreateLiveStreamRequest)
destination = double(url: "http://test.com/rmtp", key: "123abc")
allow(request).to receive(:reduced_latency=)
allow(request).to receive(:new_asset_settings=)
allow(request).to receive(:playback_policy=)
allow(request).to receive(:test=)
allow(MuxRuby::CreateLiveStreamRequest).to receive(:new).and_return(request)
allow_any_instance_of(MuxRuby::LiveStreamsApi).to receive(:create_live_stream).and_return(live_stream_data)
allow_any_instance_of(MuxRuby::LiveStreamsApi).to receive(:create_live_stream_playback_id).and_return(live_stream_playback_data)
allow_any_instance_of(MuxRuby::LiveStreamsApi).to receive(:create_live_stream_simulcast_target).and_return(live_stream_simulcast_data)
allow(MillicastDestination).to receive(:create).and_return(destination)
live_stream = MuxLiveStream.create_with_simulcast
expect(live_stream.id).to eq "stream_id"
expect(live_stream.simulcast_id).to eq "simulcast_id"
expect(live_stream.simulcast_destination).to eq destination
end
context "when test mode is enabled" do
it "does not create a simulcast" do
allow(ENV).to receive(:[]).with("MUX_TEST_MODE_DISABLED").and_return(nil)
allow(ENV).to receive(:[]).with("MUX_REDUCED_LATENCY_ENABLED").and_return("true")
request = instance_double(MuxRuby::CreateLiveStreamRequest)
destination = double(url: "http://test.com/rmtp", key: "123abc")
allow(request).to receive(:reduced_latency=)
allow(request).to receive(:new_asset_settings=)
allow(request).to receive(:playback_policy=)
allow(request).to receive(:test=)
allow(MuxRuby::CreateLiveStreamRequest).to receive(:new).and_return(request)
allow_any_instance_of(MuxRuby::LiveStreamsApi).to receive(:create_live_stream).and_return(live_stream_data)
allow_any_instance_of(MuxRuby::LiveStreamsApi).to receive(:create_live_stream_playback_id).and_return(live_stream_playback_data)
allow(MillicastDestination).to receive(:create).and_return(destination)
live_stream = MuxLiveStream.create_with_simulcast
expect(live_stream.id).to eq "stream_id"
expect(live_stream.simulcast_id).to be_nil
expect(live_stream.simulcast_destination).to be_nil
end
end
end
end