Files
old-holivud2/spec/controllers/video_release_confirmations_controller_spec.rb

318 lines
11 KiB
Ruby
Raw Normal View History

2020-05-31 22:38:19 +02:00
require "rails_helper"
RSpec.describe VideoReleaseConfirmationsController, type: :controller do
let(:admin) { create(:user, :admin) }
let(:project) { create(:project, account: admin.accounts.first) }
let(:video) { create(:video, project: project) }
before :each do
sign_in admin
end
describe "acquired_media_release" do
2020-09-16 05:39:08 +02:00
let(:acquired_media_release) { create(:acquired_media_release, :with_files) }
2020-05-31 22:38:19 +02:00
describe "#new" do
let(:edl_event_gateway) { instance_double(EdlEventGateway) }
before :each do
allow(EdlEventGateway).to receive(:new).and_return(edl_event_gateway)
allow(edl_event_gateway).to receive(:edl_events).and_return(build_list(:edl_event, 1))
end
it "assigns video_release_confirmation, video, edl_events_data" do
post :new,
params: {
video_id: video,
acquired_media_release_id: acquired_media_release,
video_release_confirmation: {
time_elapsed: nil,
timecode_in: nil,
timecode_out: nil,
duration: nil,
source_file_name: nil,
clip_name: nil,
description: nil,
2020-09-16 05:39:08 +02:00
file_id: acquired_media_release.files.first.id,
2020-05-31 22:38:19 +02:00
},
use_route: new_video_acquired_media_release_video_release_confirmation_path(video, acquired_media_release)
},
xhr: true
expect(assigns(:video_release_confirmation)).to have_attributes({
video_id: video.id,
releasable_id: acquired_media_release.id,
time_elapsed: "",
releasable_type: "AcquiredMediaRelease",
channel: "V",
timecode_in: "timecode_in",
timecode_out: "timecode_out",
duration: "duration",
source_file_name: "source_file_name",
clip_name: "clip_name",
description: "description",
2020-09-16 05:39:08 +02:00
file_id: acquired_media_release.files.first.id,
2020-05-31 22:38:19 +02:00
})
expect(assigns(:video)).to have_attributes({
id: video.id,
project_id: project.id,
analysis_status: "not_started",
analysis_started_at: nil,
name: nil,
number: nil,
report_published_at: nil
})
expect(assigns(:edl_events_data)).to eq({
edl_events: build_list(:edl_event, 1),
edl_attributes: {
channel: "V",
timecode_in: "timecode_in",
timecode_out: "timecode_out",
duration: "duration",
source_file_name: "source_file_name",
clip_name: "clip_name",
description: "description",
},
info_message: "An EDL event was found. Data is shown below",
})
end
end
describe "#create" do
it "assigns video_release_confirmations, video_release_confirmation" do
post :create,
params: {
video_id: video,
acquired_media_release_id: acquired_media_release,
video_release_confirmation: {
channel: "V",
time_elapsed: "5",
timecode_in: "01:00:00:00",
timecode_out: "01:00:05:00",
duration: "5.0",
source_file_name: "DISCLAIMER.AVI",
clip_name: "DISCLAIMER.AVI.NEW.02",
description: "Boat",
2020-09-16 05:39:08 +02:00
file_id: acquired_media_release.files.first.id,
2020-05-31 22:38:19 +02:00
},
use_route: video_acquired_media_release_video_release_confirmations_path(video, acquired_media_release)
},
xhr: true
expect(assigns(:video_release_confirmations)).to eq(video.video_release_confirmations)
expect(assigns(:video_release_confirmation)).to have_attributes({
time_elapsed: "5",
timecode_in: "01:00:00:00",
timecode_out: "01:00:05:00",
duration: "5.0",
source_file_name: "DISCLAIMER.AVI",
clip_name: "DISCLAIMER.AVI.NEW.02",
description: "Boat",
2020-09-16 05:39:08 +02:00
file_id: acquired_media_release.files.first.id,
2020-05-31 22:38:19 +02:00
})
end
it "creates a video confirmation" do
expect {
post :create,
params: {
video_id: video,
acquired_media_release_id: acquired_media_release,
video_release_confirmation: {
channel: "V",
time_elapsed: "5",
timecode_in: "01:00:00:00",
timecode_out: "01:00:05:00",
duration: "5.0",
source_file_name: "DISCLAIMER.AVI",
clip_name: "DISCLAIMER.AVI.NEW.02",
description: "Boat",
},
use_route: video_acquired_media_release_video_release_confirmations_path(video, acquired_media_release)
},
xhr: true
}.to change { VideoReleaseConfirmation.count }.from(0).to(1)
end
end
describe "#destroy" do
let!(:video_release_confirmation) { create(:video_release_confirmation, video: video, releasable: acquired_media_release) }
it "assigns releasable, video, video_release_confirmations" do
delete :destroy,
params: {
id: video_release_confirmation,
video_id: video,
use_route: video_acquired_media_release_video_release_confirmations_path(video, video_release_confirmation)
}, xhr: true
expect(assigns(:releasable)).to eq(video_release_confirmation.releasable)
expect(assigns(:video)).to eq(video)
expect(assigns(:video_release_confirmations).to_a).to eq([])
end
it "destroys video confirmation" do
expect {
delete :destroy,
params: {
id: video_release_confirmation,
video_id: video,
use_route: video_acquired_media_release_video_release_confirmations_path(video, video_release_confirmation)
},
xhr: true
}.to change { VideoReleaseConfirmation.count }.from(1).to(0)
end
end
end
describe "location_releases" do
let(:location_release) { create(:location_release) }
let(:edl_event_gateway) { instance_double(EdlEventGateway) }
describe "#new" do
before :each do
allow(EdlEventGateway).to receive(:new).and_return(edl_event_gateway)
allow(edl_event_gateway).to receive(:edl_events).and_return(build_list(:edl_event, 1))
end
it "assigns video_release_confirmation, video, edl_events_data" do
post :new,
params: {
video_id: video,
location_release_id: location_release,
video_release_confirmation: {
time_elapsed: nil,
timecode_in: nil,
timecode_out: nil,
duration: nil,
source_file_name: nil,
clip_name: nil,
description: nil,
},
use_route: new_video_location_release_video_release_confirmation_path(video, location_release)
},
xhr: true
expect(assigns(:video_release_confirmation)).to have_attributes({
video_id: video.id,
releasable_id: location_release.id,
time_elapsed: "",
releasable_type: "LocationRelease",
channel: "V",
timecode_in: "timecode_in",
timecode_out: "timecode_out",
duration: "duration",
source_file_name: "source_file_name",
clip_name: "clip_name",
description: "description",
})
expect(assigns(:video)).to have_attributes({
id: video.id,
project_id: project.id,
analysis_status: "not_started",
analysis_started_at: nil,
name: nil,
number: nil,
report_published_at: nil
})
expect(assigns(:edl_events_data)).to eq({
edl_events: build_list(:edl_event, 1),
edl_attributes: {
channel: "V",
timecode_in: "timecode_in",
timecode_out: "timecode_out",
duration: "duration",
source_file_name: "source_file_name",
clip_name: "clip_name",
description: "description",
},
info_message: "An EDL event was found. Data is shown below",
})
end
end
describe "#create" do
it "assigns video_release_confirmations, video_release_confirmation" do
post :create,
params: {
video_id: video,
location_release_id: location_release,
video_release_confirmation: {
channel: "V",
time_elapsed: "5",
timecode_in: "01:00:00:00",
timecode_out: "01:00:05:00",
duration: "5.0",
source_file_name: "DISCLAIMER.AVI",
clip_name: "DISCLAIMER.AVI.NEW.02",
description: "Boat",
},
use_route: video_location_release_video_release_confirmations_path(video, location_release)
},
xhr: true
expect(assigns(:video_release_confirmations)).to eq(video.video_release_confirmations)
expect(assigns(:video_release_confirmation)).to have_attributes({
time_elapsed: "5",
timecode_in: "01:00:00:00",
timecode_out: "01:00:05:00",
duration: "5.0",
source_file_name: "DISCLAIMER.AVI",
clip_name: "DISCLAIMER.AVI.NEW.02",
description: "Boat",
})
end
it "creates a video confirmation" do
expect {
post :create,
params: {
video_id: video,
location_release_id: location_release,
video_release_confirmation: {
time_elapsed: "5",
timecode_in: "01:00:00:00",
timecode_out: "01:00:05:00",
duration: "5.0",
source_file_name: "DISCLAIMER.AVI",
clip_name: "DISCLAIMER.AVI.NEW.02",
description: "Boat",
},
use_route: video_location_release_video_release_confirmations_path(video, location_release)
},
xhr: true
}.to change { VideoReleaseConfirmation.count }.from(0).to(1)
end
end
describe "#destroy" do
let!(:video_release_confirmation) { create(:video_release_confirmation, video: video, releasable: location_release) }
it "assigns releasable, video, video_release_confirmations" do
delete :destroy,
params: {
id: video_release_confirmation,
video_id: video,
use_route: video_location_release_video_release_confirmations_path(video, video_release_confirmation)
}, xhr: true
expect(assigns(:releasable)).to eq(video_release_confirmation.releasable)
expect(assigns(:video)).to eq(video)
expect(assigns(:video_release_confirmations).to_a).to eq([])
end
it "destroys video confirmation" do
expect {
delete :destroy,
params: {
id: video_release_confirmation,
video_id: video,
use_route: video_location_release_video_release_confirmations_path(video, video_release_confirmation)
},
xhr: true
}.to change { VideoReleaseConfirmation.count }.from(1).to(0)
end
end
end
end