Upstream sync

This commit is contained in:
Senad Uka
2020-09-16 05:39:08 +02:00
parent 5cf7be6f13
commit 28e0eb36b7
61 changed files with 419 additions and 268 deletions

View File

@@ -12,59 +12,6 @@ RSpec.describe BroadcastRecordingsController, type: :controller do
stub_mux_live_stream
end
describe "#edit" do
let(:broadcast) { create(:broadcast, project: project, name: "New Broadcast") }
let(:recording) { create(:broadcast_recording, broadcast: broadcast) }
before do
stub_mux_live_stream
end
it "assigns project, broadcast, broadcast recording" do
get :edit, params: { project_id: project, broadcast_id: broadcast, id: recording }, xhr: true
expect(assigns(:project)).to have_attributes({
id: project.id,
name: project.name,
account_id: project.account_id
})
expect(assigns(:broadcast)).to have_attributes({
id: broadcast.id,
name: broadcast.name,
project_id: project.id
})
expect(assigns(:recording)).to have_attributes({
id: recording.id,
broadcast_id: broadcast.id,
file_name: "high.mp4"
})
end
end
describe "#update" do
let(:broadcast) { create(:broadcast, project: project, name: "New Broadcast") }
let(:recording) { create(:broadcast_recording, broadcast: broadcast) }
let(:recordings) { create_list(:broadcast_recording, 5, :with_random_asset_uid, broadcast: broadcast) }
let(:starred_recordings) { create_list(:broadcast_recording, 5, :with_random_asset_uid, broadcast: broadcast, starred: true) }
before do
stub_mux_live_stream
end
it "updates the recording's name and description" do
expect(recording.name).to eq(recording.download_file_name)
expect(recording.description).to eq("No description provided for this recording.")
patch :update, params: { project_id: project, broadcast_id: broadcast, id: recording, broadcast_recording: { name: "Just for fun", description: "I had fun while making this stream." } }, xhr: true
recording.reload
expect(recording.name).to eq("Just for fun")
expect(recording.description).to eq("I had fun while making this stream.")
end
end
describe "#destroy" do
let(:broadcast) { create(:broadcast, project: project, name: "New Broadcast") }
let(:recording) { create(:broadcast_recording, broadcast: broadcast) }

View File

@@ -195,15 +195,15 @@ RSpec.describe BroadcastsController, type: :controller do
expect(response.body).to have_selector(".custom-control-label", text: "Director Mode")
end
context "when director mode is enabled" do
context "director mode is enabled by default" do
it "shows the video embed" do
get :show, params: { project_id: project, id: broadcast, director_mode: true }
get :show, params: { project_id: project, id: broadcast }
expect(response.body).to have_selector("iframe", text: "video player")
end
it "renders the view dropdown with a director mode disable option" do
get :show, params: { project_id: project, id: broadcast, director_mode: true }
get :show, params: { project_id: project, id: broadcast }
expect(response.body).to have_content broadcast.name
expect(response.body).to have_selector(".custom-control-label", text: "Director Mode")

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
RSpec.describe BroadcastRecordingStarringsController, type: :controller do
RSpec.describe Public::BroadcastRecordingStarringsController, type: :controller do
render_views
let(:user) { create(:user) }
@@ -8,7 +8,6 @@ RSpec.describe BroadcastRecordingStarringsController, type: :controller do
let(:project) { create(:project, account: user.primary_account) }
before do
sign_in user
stub_mux_live_stream
end
@@ -22,7 +21,7 @@ RSpec.describe BroadcastRecordingStarringsController, type: :controller do
expect(recording.starred).to be_falsey
end
post :create, params: { project_id: project, broadcast_id: broadcast, broadcast_recording_id: recordings.first.id }, xhr: true
post :create, params: { broadcast_token: broadcast.token, broadcast_recording_id: recordings.first.id }, xhr: true
expect(recordings.first.reload.starred).to eq true
@@ -36,7 +35,7 @@ RSpec.describe BroadcastRecordingStarringsController, type: :controller do
expect(recording.starred).to be_truthy
end
post :create, params: { project_id: project, broadcast_id: broadcast, broadcast_recording_id: starred_recordings.first.id }, xhr: true
post :create, params: { broadcast_token: broadcast.token, broadcast_recording_id: starred_recordings.first.id }, xhr: true
expect(starred_recordings.first.reload.starred).to eq false

View File

@@ -0,0 +1,59 @@
require 'rails_helper'
RSpec.describe Public::BroadcastRecordingsController, type: :controller do
render_views
let(:user) { create(:user) }
let(:account) { user.primary_account }
let(:project) { create(:project, account: user.primary_account) }
before do
stub_mux_live_stream
end
describe "#edit" do
let(:broadcast) { create(:broadcast, project: project, name: "New Broadcast") }
let(:recording) { create(:broadcast_recording, broadcast: broadcast) }
before do
stub_mux_live_stream
end
it "assigns project, broadcast, broadcast recording" do
get :edit, params: { broadcast_token: broadcast.token, id: recording }, xhr: true
expect(assigns(:broadcast)).to have_attributes({
id: broadcast.id,
name: broadcast.name,
project_id: project.id
})
expect(assigns(:recording)).to have_attributes({
id: recording.id,
broadcast_id: broadcast.id,
file_name: "high.mp4"
})
end
end
describe "#update" do
let(:broadcast) { create(:broadcast, project: project, name: "New Broadcast") }
let(:recording) { create(:broadcast_recording, broadcast: broadcast) }
let(:recordings) { create_list(:broadcast_recording, 5, :with_random_asset_uid, broadcast: broadcast) }
before do
stub_mux_live_stream
end
it "updates the recording's name and description" do
expect(recording.name).to eq(recording.download_file_name)
expect(recording.description).to eq("No description provided for this recording.")
patch :update, params: { broadcast_token: broadcast.token, id: recording, broadcast_recording: { name: "Just for fun", description: "I had fun while making this stream." } }, xhr: true
recording.reload
expect(recording.name).to eq("Just for fun")
expect(recording.description).to eq("I had fun while making this stream.")
end
end
end

View File

@@ -10,7 +10,7 @@ RSpec.describe VideoReleaseConfirmationsController, type: :controller do
end
describe "acquired_media_release" do
let(:acquired_media_release) { create(:acquired_media_release) }
let(:acquired_media_release) { create(:acquired_media_release, :with_files) }
describe "#new" do
let(:edl_event_gateway) { instance_double(EdlEventGateway) }
@@ -21,8 +21,6 @@ RSpec.describe VideoReleaseConfirmationsController, type: :controller do
end
it "assigns video_release_confirmation, video, edl_events_data" do
file_info = create(:file_info)
post :new,
params: {
video_id: video,
@@ -35,7 +33,7 @@ RSpec.describe VideoReleaseConfirmationsController, type: :controller do
source_file_name: nil,
clip_name: nil,
description: nil,
file_info_id: file_info,
file_id: acquired_media_release.files.first.id,
},
use_route: new_video_acquired_media_release_video_release_confirmation_path(video, acquired_media_release)
},
@@ -53,7 +51,7 @@ RSpec.describe VideoReleaseConfirmationsController, type: :controller do
source_file_name: "source_file_name",
clip_name: "clip_name",
description: "description",
file_info_id: file_info.id,
file_id: acquired_media_release.files.first.id,
})
expect(assigns(:video)).to have_attributes({
id: video.id,
@@ -82,8 +80,6 @@ RSpec.describe VideoReleaseConfirmationsController, type: :controller do
describe "#create" do
it "assigns video_release_confirmations, video_release_confirmation" do
file_info = create(:file_info)
post :create,
params: {
video_id: video,
@@ -97,7 +93,7 @@ RSpec.describe VideoReleaseConfirmationsController, type: :controller do
source_file_name: "DISCLAIMER.AVI",
clip_name: "DISCLAIMER.AVI.NEW.02",
description: "Boat",
file_info_id: file_info,
file_id: acquired_media_release.files.first.id,
},
use_route: video_acquired_media_release_video_release_confirmations_path(video, acquired_media_release)
},
@@ -112,7 +108,7 @@ RSpec.describe VideoReleaseConfirmationsController, type: :controller do
source_file_name: "DISCLAIMER.AVI",
clip_name: "DISCLAIMER.AVI.NEW.02",
description: "Boat",
file_info_id: file_info.id,
file_id: acquired_media_release.files.first.id,
})
end

View File

@@ -44,6 +44,16 @@ FactoryBot.define do
guardian_2_phone "2222"
end
trait :with_files do
files do
[
Rack::Test::UploadedFile.new('spec/fixtures/files/contract.pdf', 'application/pdf'),
Rack::Test::UploadedFile.new('spec/fixtures/files/audio.mp3', 'audio/mpeg'),
Rack::Test::UploadedFile.new('spec/fixtures/files/video_file.mp4', 'video/mp4')
]
end
end
factory :acquired_media_release_with_contract_template do
after(:build) do |acquired_media_release, _|
acquired_media_release.contract_template = build(:acquired_media_release_contract_template)

View File

@@ -205,34 +205,6 @@ RSpec.feature 'User manages contract templates', type: :feature do
expect(pdf_body).to have_content('Guardian')
end
context 'preventing creation of release template with wrong fee value' do
before do
visit new_project_contract_template_path(project)
fill_in 'Name', with: 'My Release Template'
select 'Appearance Release', from: 'Release type'
fill_in_trix body_field, with: 'You agree to this release.'
fill_hidden guardian_clause_field, with: 'Your minor agrees to this release.'
select 'All', from: 'Applicable Media'
select 'Other', from: 'Territory'
fill_in 'Describe other territory', with: 'North America only'
select 'In perpetuity', from: 'Term'
select 'None', from: 'Restriction'
end
scenario 'Should not allow negative fees' do
fill_in 'Fee', with: '-200'
click_on create_release_template_button
expect(page).not_to have_content(create_contract_template_success_message)
end
scenario 'Should not allow fees with more than 9 digits' do
fill_in 'Fee', with: '9999999999'
click_on create_release_template_button
expect(page).not_to have_content(create_contract_template_success_message)
end
end
scenario 'contract template preview is shown before printing' do
create(:appearance_release_contract_template, body: 'Contract legal language', project: project)
visit project_contract_templates_path(project)

View File

@@ -186,6 +186,30 @@ feature 'User managing broadcasts' do
expect(page).not_to have_selector("li.media.playing-highlight")
end
scenario 'opening broadcast page starts in normal mode if director mode is not available' do
broadcast = create(:broadcast, :with_stream, :with_files, project: project)
broadcast.director_mode_video_embed = nil
broadcast.save
visit project_broadcast_path(project, broadcast)
expect(page).not_to have_selector('#director_broadcast_video')
expect(page).to have_selector('#broadcast_video')
expect(page).not_to have_selector('#director_mode_switch')
end
scenario 'opening broadcast page starts in director mode if available' do
broadcast = create(:broadcast, :with_stream, :with_files, project: project, director_mode_video_embed: 'director_mode')
visit project_broadcast_path(project, broadcast)
expect(page).not_to have_selector('#broadcast_video')
expect(page).to have_selector('#director_broadcast_video')
expect(page).to have_selector('#director_mode_switch')
end
context 'When the user is associate' do
let(:current_user) { create(:user, :associate) }

View File

@@ -83,11 +83,7 @@ feature "User performs video analysis" do
create(:material_release, name: "Apple MacBook Air", project: project),
create(:material_release, name: "Microsoft Surface Pro", project: project)
]
acquired_media = create(:acquired_media_release, project: project)
acquired_file_info_1, acquired_file_info_2 = [
create(:file_info, filename: "Still Image", releasable: acquired_media),
create(:file_info, filename: "Artwork", releasable: acquired_media)
]
acquired_media = create(:acquired_media_release, :with_files, project: project)
music_release = create(:music_release, project: project)
music_file_info_1, music_file_info_2 = [
create(:file_info, filename: "I'm not afraid", releasable: music_release),
@@ -116,9 +112,10 @@ feature "User performs video analysis" do
end
within "#acquired_media_releases_section" do
search_for(:acquired_media_releases, text: "till")
expect(page).to have_content("Still Image")
expect(page).not_to have_content("Artwork")
search_for(:acquired_media_releases, text: "cont")
expect(page).to have_content("contract.pdf")
expect(page).not_to have_content("audio.mp3")
expect(page).not_to have_content("video_file.mp4")
end
within "#music_releases_section" do
@@ -350,34 +347,31 @@ feature "User performs video analysis" do
end
scenario "confirming an acquired media release", js: true do
acquired_media_release = create(:acquired_media_release_with_file_infos, project: project)
acquired_media_release.file_infos.first.update(filename: "shark jumping")
acquired_media_release.file_infos.second.update(filename: "pig flying")
acquired_media_release.file_infos.third.update(filename: "panda sneezing")
acquired_media_release = create(:acquired_media_release, :with_files, project: project)
sign_in current_user
visit video_video_analyses_path(video)
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "shark jumping", count: 1)
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "pig flying", count: 1)
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "panda sneezing", count: 1)
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "contract.pdf", count: 1)
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "audio.mp3", count: 1)
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "video_file.mp4", count: 1)
confirm_first_release_using_edl_modal(video, acquired_media_release, text: "shark jumping")
confirm_first_release_using_edl_modal(video, acquired_media_release, text: "contract.pdf")
expect(page).to have_confirmed_release(acquired_media_release, text: "shark jumping")
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "pig flying", count: 1)
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "panda sneezing", count: 1)
expect(page).to have_confirmed_release(acquired_media_release, text: "contract.pdf")
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "audio.mp3", count: 1)
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "video_file.mp4", count: 1)
unconfirm_release(VideoReleaseConfirmation.last)
expect(page).not_to have_confirmed_release(acquired_media_release, text: "shark jumping")
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "shark jumping", count: 1)
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "pig flying", count: 1)
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "panda sneezing", count: 1)
expect(page).not_to have_confirmed_release(acquired_media_release, text: "contract.pdf")
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "contract.pdf", count: 1)
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "audio.mp3", count: 1)
expect(page).to have_unconfirmed_file_info_release(acquired_media_release, "video_file.mp4", count: 1)
end
scenario "confirming a material release", js: true do
material_release = create(:material_release, project: project)
material_release = create(:material_release, :with_file, project: project)
sign_in current_user
visit video_video_analyses_path(video)
@@ -387,7 +381,6 @@ feature "User performs video analysis" do
confirm_first_release_using_edl_modal(video, material_release)
expect(page).to have_confirmed_release(material_release)
expect(page).not_to have_unconfirmed_release(material_release)
unconfirm_release(VideoReleaseConfirmation.last)

View File

@@ -22,14 +22,10 @@ describe ContractTemplate do
it { is_expected.to validate_presence_of(:release_type) }
end
describe '#fee' do
it { is_expected.to monetize(:fee) }
end
describe '#fee?' do
it 'returns true when there is a fee amount' do
fee_contract = build(:contract_template, fee: 500)
no_fee_contract = build(:contract_template, fee: 0)
no_fee_contract = build(:contract_template, fee: nil)
expect(fee_contract).to be_fee
expect(no_fee_contract).not_to be_fee

View File

@@ -4,7 +4,6 @@ RSpec.describe VideoReleaseConfirmation do
describe "associations" do
it { is_expected.to belong_to(:releasable) }
it { is_expected.to belong_to(:video) }
it { is_expected.to belong_to(:file_info).optional }
end
describe "#appears_at" do