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,56 @@
require "rails_helper"
module ExcelReports
module VideoReports
RSpec.describe DiscoveryProductionElementsLog do
let(:video) { create(:video) }
describe "#to_xls" do
it "generates an excel report" do
expect(described_class.new(video).to_xls).not_to be_nil
end
it "builds the necessary worksheets" do
allow(DiscoveryProductionElementsLogs::MediaRightsCertificationSheet).to receive(:build)
allow(DiscoveryProductionElementsLogs::AcquiredFootageAndStillsSheet).to receive(:build)
allow(DiscoveryProductionElementsLogs::MusicSheet).to receive(:build)
allow(DiscoveryProductionElementsLogs::TalentSheet).to receive(:build)
allow(DiscoveryProductionElementsLogs::AppearanceSheet).to receive(:build)
allow(DiscoveryProductionElementsLogs::LocationSheet).to receive(:build)
allow(DiscoveryProductionElementsLogs::NameProductLogoSheet).to receive(:build)
allow(DiscoveryProductionElementsLogs::ProductIntegrationSheet).to receive(:build)
described_class.new(video).to_xls
expect(DiscoveryProductionElementsLogs::MediaRightsCertificationSheet).to have_received(:build)
expect(DiscoveryProductionElementsLogs::AcquiredFootageAndStillsSheet).to have_received(:build)
expect(DiscoveryProductionElementsLogs::MusicSheet).to have_received(:build)
expect(DiscoveryProductionElementsLogs::TalentSheet).to have_received(:build)
expect(DiscoveryProductionElementsLogs::AppearanceSheet).to have_received(:build)
expect(DiscoveryProductionElementsLogs::LocationSheet).to have_received(:build)
expect(DiscoveryProductionElementsLogs::NameProductLogoSheet).to have_received(:build)
expect(DiscoveryProductionElementsLogs::ProductIntegrationSheet).to have_received(:build)
end
it "sorts the worksheet data by timecode in" do
confirmations = double(:video_release_confirmations)
allow(video).to receive(:video_release_confirmations).and_return(confirmations)
allow(confirmations).to receive(:where).and_return(confirmations)
allow(confirmations).to receive(:order).and_return([])
described_class.new(video).to_xls
expect(video).to have_received(:video_release_confirmations).exactly(6).times
expect(confirmations).to have_received(:where).exactly(6).times
expect(confirmations).to have_received(:order).with(timecode_in: :asc).exactly(6).times
end
end
describe "#filename" do
it "returns video file filename concatenated with production-elements-log and given format" do
expect(described_class.new(video).filename("csv")).to eq "video_file-mp4_production-elements-log.csv"
end
end
end
end
end

View File

@@ -0,0 +1,146 @@
require "rails_helper"
module ExcelReports
module VideoReports
module DiscoveryProductionElementsLogs
RSpec.describe AcquiredFootageAndStillsSheet do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
it_behaves_like "a worksheet" do
subject { described_class.new(workbook) }
end
describe "#title" do
it "returns 'Acquired Footage & Stills'" do
expect(described_class.new(workbook).title).to eq "Acquired Footage & Stills"
end
end
describe "#fill_content" do
it "adds content from acquired media release" do
instructions = <<~INSTRUCTIONS
All licenses must conform to the DCI contractual requirements and must be fully executed.
Releases, licenses and agreements should only be logged once, based on the order of their appearance in the program.
If an image does not appear in the final Program, log that release after those in the final Program; indicate on the Log sheet NOT IN FINAL PROGRAM and list the camera tape only.
Refer to the source of all third party footage in the exact form as it appears on the release.
Please note that if it is not possible to deliver an English language agreement, an English language translation must accompany any agreement delivered in a foreign language (if applicable).
INSTRUCTIONS
user = create(:user)
project = create(:project, account:user.primary_account)
video = create(:video,
project: project,
number: "45",
name: "Amazing Race",
)
acquired_media_release = create(:acquired_media_release,
project: project,
applicable_medium: ApplicableMedium.last,
territory: Territory.last,
term: Term.last,
restriction: Restriction.last,
name: "Licensor",
person_phone: "1-800-978-2343",
)
confirmation = create(:video_release_confirmation,
video: video,
releasable: acquired_media_release,
source_file_name: "source_file_name",
clip_name: "clippy",
timecode_in: "timecode_in",
timecode_out: "timecode_out",
duration: "duration",
description: "description",
)
wrapped_confirmation = ReleasableDataAdapter.new(confirmation)
sheet = instance_double(Axlsx::Worksheet, :sheet)
expect(sheet).to receive(:add_row).with(["ACQUIRED FOOTAGE/STILLS/ PUBLIC DOMAIN LOG (for all episodes/programs)"])
expect(sheet).to receive(:add_row).with([instructions])
expect(sheet).to receive(:add_row).with(no_args)
expect(sheet).to receive(:add_row).with(["EPISODE NUMBER", "EPISODE TITLE", "CLIP #", "PROGRAM MASTER TC", "", "TOTAL TIME", "BRIEF VIDEO DESCRIPTION", "LICENSOR\n(incl phone number)", "EXPLOITABLE RIGHTS", "", "", "DCL Rights Waiver Uploaded?"])
expect(sheet).to receive(:add_row).with(["", "", "", "IN", "OUT", "", "", "", "MEDIA", "TERRITORY", "TERM", ""])
expect(sheet).to receive(:add_row).with(["45", "Amazing Race", "source_file_name - clippy", "timecode_in", "timecode_out", "duration", "description", "Licensor\n1-800-978-2343", "All", "Worldwide", "In perpetuity", "None"])
described_class.new(workbook, [wrapped_confirmation]).fill_content(sheet)
end
end
describe "#format" do
let(:sheet) { instance_double(Axlsx::Worksheet, :sheet) }
before :each do
allow(sheet).to receive(:column_widths)
allow(sheet).to receive(:merge_cells)
end
it "sets sheet column widths to 10, 20, 25, 15, 15, 15, 20, 15, 15, 15, 15, 10" do
expect(sheet).to receive(:column_widths).with(10, 20, 25, 15, 15, 15, 20, 15, 15, 15, 15, 10)
described_class.new(workbook).format(sheet)
end
it "merges columns A1:M1 A2:M2 A4:A5 B4:B5 C4:C5 D4:E4 F4:F5 G4:G5 H4:H5 I4:K4 L4:L5" do
%w(A1:M1 A2:M2 A4:A5 B4:B5 C4:C5 D4:E4 F4:F5 G4:G5 H4:H5 I4:K4 L4:L5).each do |cell|
expect(sheet).to receive(:merge_cells).with(cell)
end
described_class.new(workbook).format(sheet)
end
end
describe "#style" do
it "sets sheet style" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
expect(sheet).to receive(:add_style).with("A1", { b: true }, { sz: 14 })
expect(sheet).to receive(:add_style).with("A2", { sz: 10 })
expect(sheet).to receive(:add_style).with(
"A4:L4",
{
bg_color: "97CBFC",
b: true,
border: { :style => :thick, :color => "000000" },
alignment: { :horizontal => :center, :vertical => :center, :wrap_text => true },
sz: 8,
}
)
expect(sheet).to receive(:add_style).with(
"B5:L5",
{
bg_color: "97CBFC",
b: true,
border: { :style => :thick, :color => "000000" },
alignment: { :horizontal => :center, :vertical => :center, :wrap_text => true },
sz: 8,
}
)
expect(sheet).to receive(:add_style).with(
"A4",
{
alignment: { :wrap_text => true },
}
)
expect(sheet).to receive(:add_style).with(
"L4",
{
alignment: { :wrap_text => true },
}
)
expect(sheet).to receive(:add_style).at_least(1).with("A6:L7",
{
border: { style: :thick, color: "000000" },
alignment: { wrap_text: true },
sz: 10
}
)
described_class.new(workbook, ["data1", "data2"]).style(sheet)
end
end
end
end
end
end

View File

@@ -0,0 +1,74 @@
require "rails_helper"
module ExcelReports
module VideoReports
module DiscoveryProductionElementsLogs
RSpec.describe AppearanceSheet do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
it_behaves_like "a worksheet" do
subject { described_class.new(workbook) }
end
describe "#title" do
it "returns 'Appearance'" do
expect(described_class.new(workbook).title).to eq "Appearance"
end
end
describe "#fill_content" do
it "adds content from the data" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
releasable_datum = ReleasableDataAdapter.new(
build(:video_release_confirmation,
timecode_in: "00:00:05:00",
time_elapsed: 1,
source_file_name: "source",
clip_name: "clip",
description: "old, male, brunette",
video: build(:video, name: "My Video", number: 1),
releasable: build(:appearance_release, person_first_name: "John", person_last_name: "Doe")
)
)
allow(sheet).to receive(:add_row)
release_log = described_class.new(workbook, [releasable_datum])
release_log.fill_content(sheet)
expect(sheet).to have_received(:add_row).with([
"1",
"My Video",
"00:00:05:00",
"source - clip",
"John Doe",
"old, male, brunette",
])
end
end
describe "#format" do
let(:sheet) { instance_double(Axlsx::Worksheet, :sheet) }
before :each do
allow(sheet).to receive(:column_widths)
allow(sheet).to receive(:merge_cells)
end
it "sets sheet column widths to 20, 25, 20, 20, 25, 30" do
expect(sheet).to receive(:column_widths).with(20, 25, 20, 20, 25, 30)
described_class.new(workbook).format(sheet)
end
it "merges columns A2:F2" do
%w(A2:F2).each do |cell|
expect(sheet).to receive(:merge_cells).with(cell)
end
described_class.new(workbook).format(sheet)
end
end
end
end
end
end

View File

@@ -0,0 +1,65 @@
require "rails_helper"
module ExcelReports
module VideoReports
module DiscoveryProductionElementsLogs
RSpec.describe LocationSheet do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
it_behaves_like "a worksheet" do
subject { described_class.new(workbook) }
end
describe "#title" do
it "returns 'Location'" do
expect(described_class.new(workbook).title).to eq "Location"
end
end
describe "#fill_content" do
it "adds content from the data" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
releasable_datum = ReleasableDataAdapter.new(
build(:video_release_confirmation,
timecode_in: "00:00:05:00",
time_elapsed: 1,
source_file_name: "source",
clip_name: "clip",
description: "restaurant",
video: build(:video, name: "My Video", number: 1),
releasable: build(:location_release, name: "Frank's Taco Shack")
)
)
allow(sheet).to receive(:add_row)
release_log = described_class.new(workbook, [releasable_datum])
release_log.fill_content(sheet)
expect(sheet).to have_received(:add_row).with([
"1",
"My Video",
"00:00:05:00",
"source - clip",
"Frank's Taco Shack restaurant",
])
end
end
describe "#format" do
let(:sheet) { instance_double(Axlsx::Worksheet, :sheet) }
before :each do
allow(sheet).to receive(:column_widths)
allow(sheet).to receive(:merge_cells)
end
it "sets sheet column widths to 20, 20, 15, 20, 40" do
expect(sheet).to receive(:column_widths).with(20, 20, 15, 20, 40)
described_class.new(workbook).format(sheet)
end
end
end
end
end
end

View File

@@ -0,0 +1,44 @@
require "rails_helper"
module ExcelReports
module VideoReports
module DiscoveryProductionElementsLogs
RSpec.describe MediaRightsCertificationSheet do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
it_behaves_like "a worksheet" do
subject { described_class.new(workbook) }
end
describe "#title" do
it "returns 'Media Rights Certification'" do
expect(described_class.new(workbook).title).to eq "Media Rights Certification"
end
end
describe "#format" do
let(:sheet) { instance_double(Axlsx::Worksheet, :sheet) }
before :each do
allow(sheet).to receive(:column_widths)
allow(sheet).to receive(:merge_cells)
end
it "sets sheet column widths to 10, 20, 10, 10, 10, 10, 10, 10, 10, 10" do
expect(sheet).to receive(:column_widths).with(10, 20, 10, 10, 10, 10, 10, 10, 10, 10)
described_class.new(workbook).format(sheet)
end
it "merges columns A1:J1 A2:J2 A3:J3 B4:J4 B5:J5 B6:J6 A8:J8 B9:J9 B10:J10 B11:J11 B12:J12 B13:J13 A14:J14 A15:J15" do
%w(A1:J1 A2:J2 A3:J3 B4:J4 B5:J5 B6:J6 A8:J8 B9:J9 B10:J10 B11:J11 B12:J12 B13:J13 A14:J14 A15:J15).each do |cell|
expect(sheet).to receive(:merge_cells).with(cell)
end
described_class.new(workbook).format(sheet)
end
end
end
end
end
end

View File

@@ -0,0 +1,98 @@
require "rails_helper"
module ExcelReports
module VideoReports
module DiscoveryProductionElementsLogs
RSpec.describe MusicSheet do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
it_behaves_like "a worksheet" do
subject { described_class.new(workbook) }
end
describe "#title" do
it "returns 'Music'" do
expect(described_class.new(workbook).title).to eq "Music"
end
end
describe "#fill_content" do
it "adds content from music release" do
user = create(:user)
project = create(:project, account:user.primary_account)
video = create(:video,
project: project,
number: "45",
name: "Amazing Race",
)
confirmation = create(:audio_confirmation,
video: video,
source_file_name: "source_file_name",
composer_info: "composer1, affiliation, 50%|composer2, affiliation, 50%",
publisher_info: "publisher1, affiliation, 50%|publisher2, affiliation, 50%",
confirmation_type: "original_music"
)
wrapped_confirmation = ReleasableDataAdapter.new(confirmation)
sheet = instance_double(Axlsx::Worksheet, :sheet)
expect(sheet).to receive(:add_row).with(["MUSIC LOG (for all episodes/programs) for commissioned work-for-hire music only"])
expect(sheet).to receive(:add_row).with(["Not applicable if program contains 100% library"])
expect(sheet).to receive(:add_row).with(["Episode Title(s) or list \"All\"", "TRACK TITLE", "COMPOSER", "PUBLISHER"])
expect(sheet).to receive(:add_row).with(["Amazing Race", "source_file_name", "composer1, affiliation, 50%\ncomposer2, affiliation, 50%", "publisher1, affiliation, 50%\npublisher2, affiliation, 50%"])
described_class.new(workbook, [wrapped_confirmation]).fill_content(sheet)
end
end
describe "#format" do
let(:sheet) { instance_double(Axlsx::Worksheet, :sheet) }
before :each do
allow(sheet).to receive(:column_widths)
allow(sheet).to receive(:merge_cells)
end
it "sets sheet column widths to 20, 20, 30, 60" do
expect(sheet).to receive(:column_widths).with(20, 20, 30, 60)
described_class.new(workbook).format(sheet)
end
end
describe "#style" do
it "sets sheet style" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
expect(sheet).to receive(:add_style).with("A1", { b: true }, { sz: 14 })
expect(sheet).to receive(:add_style).with("A2", { sz: 14 })
expect(sheet).to receive(:add_style).with(
"A3:D3",
{
bg_color: "97CBFC",
b: true,
border: { :style => :thick, :color => "000000" },
alignment: { :horizontal => :center, :vertical => :center, :wrap_text => true },
sz: 8,
}
)
expect(sheet).to receive(:add_style).with(
"A3",
{
alignment: { :wrap_text => true },
}
)
expect(sheet).to receive(:add_style).at_least(1).with(
"A4:D5",
{
border: { style: :thick, color: "000000" },
alignment: { wrap_text: true },
sz: 10
}
)
described_class.new(workbook, ["data1", "data2"]).style(sheet)
end
end
end
end
end
end

View File

@@ -0,0 +1,65 @@
require "rails_helper"
module ExcelReports
module VideoReports
module DiscoveryProductionElementsLogs
RSpec.describe NameProductLogoSheet do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
it_behaves_like "a worksheet" do
subject { described_class.new(workbook) }
end
describe "#title" do
it "returns 'Name Product Logo'" do
expect(described_class.new(workbook).title).to eq "Name Product Logo"
end
end
describe "#fill_content" do
it "adds content from the data" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
releasable_datum = ReleasableDataAdapter.new(
build(:video_release_confirmation,
timecode_in: "00:00:05:00",
time_elapsed: 1,
source_file_name: "source",
clip_name: "clip",
description: "brand, can, soda",
video: build(:video, name: "My Video", number: 1),
releasable: build(:material_release, name: "Coca Cola")
)
)
allow(sheet).to receive(:add_row)
release_log = described_class.new(workbook, [releasable_datum])
release_log.fill_content(sheet)
expect(sheet).to have_received(:add_row).with([
"1",
"My Video",
"00:00:05:00",
"source - clip",
"Coca Cola",
])
end
end
describe "#format" do
let(:sheet) { instance_double(Axlsx::Worksheet, :sheet) }
before :each do
allow(sheet).to receive(:column_widths)
allow(sheet).to receive(:merge_cells)
end
it "sets sheet column widths to 15, 25, 15, 20, 40" do
expect(sheet).to receive(:column_widths).with(15, 25, 15, 20, 40)
described_class.new(workbook).format(sheet)
end
end
end
end
end
end

View File

@@ -0,0 +1,44 @@
require "rails_helper"
module ExcelReports
module VideoReports
module DiscoveryProductionElementsLogs
RSpec.describe ProductIntegrationSheet do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
it_behaves_like "a worksheet" do
subject { described_class.new(workbook) }
end
describe "#title" do
it "returns 'Product Integration'" do
expect(described_class.new(workbook).title).to eq "Product Integration"
end
end
describe "#format" do
let(:sheet) { instance_double(Axlsx::Worksheet, :sheet) }
before :each do
allow(sheet).to receive(:column_widths)
allow(sheet).to receive(:merge_cells)
end
it "sets sheet column widths to 15, 15, 15, 15, 15, 15, 15, 15, 15, 15" do
expect(sheet).to receive(:column_widths).with(15, 15, 15, 15, 15, 15, 15, 15, 15, 15)
described_class.new(workbook).format(sheet)
end
it "merges columns A4:A5 B4:B5 C4:C5 D4:D5 E4:E5 F4:F5 G4:G5 H4:H5 I4:J4" do
%w(A4:A5 B4:B5 C4:C5 D4:D5 E4:E5 F4:F5 G4:G5 H4:H5 I4:J4).each do |cell|
expect(sheet).to receive(:merge_cells).with(cell)
end
described_class.new(workbook).format(sheet)
end
end
end
end
end
end

View File

@@ -0,0 +1,59 @@
require "rails_helper"
module ExcelReports
module VideoReports
module DiscoveryProductionElementsLogs
RSpec.describe TalentSheet do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
it_behaves_like "a worksheet" do
subject { described_class.new(workbook) }
end
describe "#title" do
it "returns 'Talent'" do
expect(described_class.new(workbook).title).to eq "Talent"
end
end
describe "#fill_content" do
it "adds content from the data" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
releasable_datum = ReleasableDataAdapter.new(
build(:video_release_confirmation,
video: build(:video, name: "My Video", number: 1),
releasable: build(:talent_release, person_first_name: "John", person_last_name: "Doe")
)
)
allow(sheet).to receive(:add_row)
release_log = described_class.new(workbook, [releasable_datum])
release_log.fill_content(sheet)
expect(sheet).to have_received(:add_row).with([
"1",
"My Video",
"",
"John Doe",
])
end
end
describe "#format" do
let(:sheet) { instance_double(Axlsx::Worksheet, :sheet) }
before :each do
allow(sheet).to receive(:column_widths)
allow(sheet).to receive(:merge_cells)
end
it "sets sheet column widths to 20, 20, 30, 60" do
expect(sheet).to receive(:column_widths).with(20, 20, 30, 60)
described_class.new(workbook).format(sheet)
end
end
end
end
end
end

View File

@@ -0,0 +1,53 @@
require "rails_helper"
module ExcelReports
module VideoReports
RSpec.describe NatGeoLegalBinderLog, type: :model do
let(:video) { create(:video) }
subject { described_class.new(video) }
describe "#to_xls" do
it "generates an excel report" do
expect(subject.to_xls).not_to be_nil
end
it "builds the necessary worksheets" do
allow(NatGeoLegalBinderLogs::LegalBinderChecklistSheet).to receive(:build)
allow(NatGeoLegalBinderLogs::AppearanceReleaseLogSheet).to receive(:build)
allow(NatGeoLegalBinderLogs::LocationReleaseLogSheet).to receive(:build)
allow(NatGeoLegalBinderLogs::AcquiredFootageLogSheet).to receive(:build)
allow(NatGeoLegalBinderLogs::ThirdPartyContractLogSheet).to receive(:build)
allow(NatGeoLegalBinderLogs::ProductionPersonnelLogSheet).to receive(:build)
described_class.new(video).to_xls
expect(NatGeoLegalBinderLogs::LegalBinderChecklistSheet).to have_received(:build)
expect(NatGeoLegalBinderLogs::LocationReleaseLogSheet).to have_received(:build)
expect(NatGeoLegalBinderLogs::AcquiredFootageLogSheet).to have_received(:build)
expect(NatGeoLegalBinderLogs::ThirdPartyContractLogSheet).to have_received(:build)
expect(NatGeoLegalBinderLogs::ProductionPersonnelLogSheet).to have_received(:build)
end
it "sorts the worksheet data by timecode in" do
confirmations = double(:video_release_confirmations)
allow(video).to receive(:video_release_confirmations).and_return(confirmations)
allow(confirmations).to receive(:where).and_return(confirmations)
allow(confirmations).to receive(:order).and_return([])
described_class.new(video).to_xls
expect(video).to have_received(:video_release_confirmations).exactly(3).times
expect(confirmations).to have_received(:where).exactly(3).times
expect(confirmations).to have_received(:order).with(timecode_in: :asc).exactly(3).times
end
end
describe "#filename" do
it "includes video file filename, report title, and format" do
expect(subject.filename).to eq "video_file-mp4_legal-binder-log.xlsx"
end
end
end
end
end

View File

@@ -0,0 +1,88 @@
require "rails_helper"
module ExcelReports
module VideoReports
module NatGeoLegalBinderLogs
RSpec.describe AcquiredFootageLogSheet, type: :model do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
subject { described_class.new(workbook, []) }
it_behaves_like "a worksheet"
describe "#title" do
it "returns the title of the sheet" do
expect(subject.title).to eq "Acquired Footage-Stills Log"
end
end
describe "#fill_content" do
it "adds content from the data" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
releasable_datum = ReleasableDataAdapter.new(
build(:video_release_confirmation,
source_file_name: "source",
clip_name: "clippy",
timecode_in: "00:00:05:00",
timecode_out: "00:00:10:00",
duration: "00:00:15",
description: "Media description",
releasable: build(:acquired_media_release,
applicable_medium: ApplicableMedium.last,
territory: Territory.last,
term: Term.last,
restriction: Restriction.last,
name: "Licensor",
person_address_street1: "123 Main Street",
person_address_city: "New York",
person_address_state: "NY",
person_address_zip: "10000",
)
)
)
allow(sheet).to receive(:add_row)
release_log = described_class.new(workbook, [releasable_datum])
release_log.fill_content(sheet)
expect(sheet).to have_received(:add_row).with([
1,
"Media description",
"00:00:05:00",
"00:00:10:00",
"Licensor\n123 Main Street, New York, NY 10000",
"All",
"Worldwide",
"In perpetuity",
"None",
])
end
end
describe "#format" do
it "sets column widths and merges cells" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:column_widths)
allow(sheet).to receive(:merge_cells)
subject.format(sheet)
expect(sheet).to have_received(:column_widths)
expect(sheet).to have_received(:merge_cells).at_least(1).times
end
end
describe "#style" do
it "sets sheet style" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:add_style)
subject.style(sheet)
expect(sheet).to have_received(:add_style).at_least(1).times
end
end
end
end
end
end

View File

@@ -0,0 +1,75 @@
require "rails_helper"
module ExcelReports
module VideoReports
module NatGeoLegalBinderLogs
RSpec.describe AppearanceReleaseLogSheet, type: :model do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
subject { described_class.new(workbook, []) }
it_behaves_like "a worksheet"
describe "#title" do
it "returns the title of the sheet" do
expect(subject.title).to eq "Appearance Release Log"
end
end
describe "#fill_content" do
it "adds content from the data" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
releasable_datum = ReleasableDataAdapter.new(
build(:video_release_confirmation,
timecode_in: "00:00:05:00",
releasable: build(:appearance_release,
applicable_medium: ApplicableMedium.last,
territory: Territory.last,
term: Term.last,
restriction: Restriction.last,
person_first_name: "John",
person_last_name: "Doe",
person_address: "123 Main Street, New York, NY 10000")
)
)
allow(sheet).to receive(:add_row)
release_log = described_class.new(workbook, [releasable_datum])
release_log.fill_content(sheet)
expect(sheet).to have_received(:add_row).with([
1,
"00:00:05:00",
"John Doe\n123 Main Street, New York, NY 10000",
"All", "Worldwide", "In perpetuity", "", "None",
])
end
end
describe "#format" do
it "sets column widths and merges cells" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:column_widths)
allow(sheet).to receive(:merge_cells)
subject.format(sheet)
expect(sheet).to have_received(:column_widths)
expect(sheet).to have_received(:merge_cells).at_least(1).times
end
end
describe "#style" do
it "sets sheet style" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:add_style)
subject.style(sheet)
expect(sheet).to have_received(:add_style).at_least(1).times
end
end
end
end
end
end

View File

@@ -0,0 +1,59 @@
require "rails_helper"
module ExcelReports
module VideoReports
module NatGeoLegalBinderLogs
RSpec.describe LegalBinderChecklistSheet, type: :model do
let(:video) { build(:video, number: 1, name: "My Episode") }
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
subject { described_class.new(workbook, [], video) }
it_behaves_like "a worksheet"
describe "#title" do
it "returns the title of the sheet" do
expect(subject.title).to eq "Legal Binder Checklist"
end
end
describe "#fill_content" do
it "adds content from the video" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:add_row)
subject.fill_content(sheet)
expect(sheet).to have_received(:add_row).with(["SERIES TITLE:", ""])
expect(sheet).to have_received(:add_row).with(["EPISODE NUMBER:","1"])
expect(sheet).to have_received(:add_row).with(["EPISODE TITLE:", "My Episode"])
end
end
describe "#format" do
it "sets column widths and merges cells" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:column_widths)
allow(sheet).to receive(:merge_cells)
subject.format(sheet)
expect(sheet).to have_received(:column_widths)
expect(sheet).to have_received(:merge_cells).at_least(1).times
end
end
describe "#style" do
it "sets sheet style" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:add_style)
subject.style(sheet)
expect(sheet).to have_received(:add_style).at_least(1).times
end
end
end
end
end
end

View File

@@ -0,0 +1,78 @@
require "rails_helper"
module ExcelReports
module VideoReports
module NatGeoLegalBinderLogs
RSpec.describe LocationReleaseLogSheet, type: :model do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
subject { described_class.new(workbook, []) }
it_behaves_like "a worksheet"
describe "#title" do
it "returns the title of the sheet" do
expect(subject.title).to eq "Location Release Log"
end
end
describe "#fill_content" do
it "adds content from the data" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
releasable_datum = ReleasableDataAdapter.new(
build(:video_release_confirmation,
timecode_in: "00:00:05:00",
releasable: build(:location_release,
applicable_medium: ApplicableMedium.last,
territory: Territory.last,
term: Term.last,
restriction: Restriction.last,
name: "My Location",
address_street1: "123 Main Street",
address_city: "New York",
address_state: "NY",
address_zip: "10000")
)
)
allow(sheet).to receive(:add_row)
release_log = described_class.new(workbook, [releasable_datum])
release_log.fill_content(sheet)
expect(sheet).to have_received(:add_row).with([
1,
"00:00:05:00",
"My Location\n123 Main Street, New York, NY 10000",
"",
"All", "Worldwide", "In perpetuity", "", "None",
])
end
end
describe "#format" do
it "sets column widths and merges cells" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:column_widths)
allow(sheet).to receive(:merge_cells)
subject.format(sheet)
expect(sheet).to have_received(:column_widths)
expect(sheet).to have_received(:merge_cells).at_least(1).times
end
end
describe "#style" do
it "sets sheet style" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:add_style)
subject.style(sheet)
expect(sheet).to have_received(:add_style).at_least(1).times
end
end
end
end
end
end

View File

@@ -0,0 +1,54 @@
require "rails_helper"
module ExcelReports
module VideoReports
module NatGeoLegalBinderLogs
RSpec.describe ProductionPersonnelLogSheet, type: :model do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
subject { described_class.new(workbook, []) }
it_behaves_like "a worksheet"
describe "#title" do
it "returns the title of the sheet" do
expect(subject.title).to eq "Production Personnel Log"
end
end
describe "#fill_content" do
it "adds content for the table" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:add_row)
subject.fill_content(sheet)
expect(sheet).to have_received(:add_row).exactly(12).times
end
end
describe "#format" do
it "sets column widths and merges cells" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:column_widths)
subject.format(sheet)
expect(sheet).to have_received(:column_widths)
end
end
describe "#style" do
it "sets sheet style" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:add_style)
subject.style(sheet)
expect(sheet).to have_received(:add_style).at_least(1).times
end
end
end
end
end
end

View File

@@ -0,0 +1,56 @@
require "rails_helper"
module ExcelReports
module VideoReports
module NatGeoLegalBinderLogs
RSpec.describe ThirdPartyContractLogSheet, type: :model do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
subject { described_class.new(workbook, []) }
it_behaves_like "a worksheet"
describe "#title" do
it "returns the title of the sheet" do
expect(subject.title).to eq "Third Party Contract Log"
end
end
describe "#fill_content" do
it "adds content for the table" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:add_row)
subject.fill_content(sheet)
expect(sheet).to have_received(:add_row).exactly(13).times
end
end
describe "#format" do
it "sets column widths and merges cells" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:column_widths)
allow(sheet).to receive(:merge_cells)
subject.format(sheet)
expect(sheet).to have_received(:column_widths)
expect(sheet).to have_received(:merge_cells).at_least(1).times
end
end
describe "#style" do
it "sets sheet style" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:add_style)
subject.style(sheet)
expect(sheet).to have_received(:add_style).at_least(1).times
end
end
end
end
end
end

View File

@@ -0,0 +1,134 @@
require "rails_helper"
module ExcelReports
module VideoReports
RSpec.describe ReleasableDataAdapter do
let(:user) { create(:user) }
let(:project) { create(:project, account:user.primary_account, description: "This is the video project description.") }
let(:video) { create(:video, project: project, number: "45", name: "Amazing Race") }
let(:acquired_media_release) { create(:acquired_media_release, project: project, name: "releasable name", person_address_street1: "contact_address") }
let(:confirmation) do
create(:video_release_confirmation,
video: video,
releasable: acquired_media_release,
clip_name: "clippy",
timecode_in: "timecode_in",
timecode_out: "timecode_out",
duration: "duration",
description: "description",
source_file_name: "cat.mov"
)
end
subject { described_class.new(confirmation) }
describe "#description" do
context "when confirmation contains description" do
it "returns description from confirmation" do
expect(subject.description).to eq "description"
end
end
context "when confirmation does NOT contain description" do
it "returns project description" do
confirmation.description = nil
expect(subject.description).to eq "This is the video project description."
end
end
end
describe "#episode_number" do
it "returns video number" do
expect(subject.episode_number).to eq "45"
end
end
describe "#episode_title" do
it "returns video name" do
expect(subject.episode_title).to eq "Amazing Race"
end
end
describe "#name" do
it "returns releasable name" do
expect(subject.name).to eq "releasable name"
end
end
describe "#source_file_name" do
it "returns source_file_name from confirmation" do
expect(subject.source_file_name).to eq "cat.mov"
end
end
describe "#clip_name" do
it "returns clip_name from confirmation" do
expect(subject.clip_name).to eq "clippy"
end
end
describe "#source_file_and_clip_names" do
context "when source_file_name and clip_name present" do
it "returns source_file_name and clip_name from confirmation joined by -" do
expect(subject.source_file_and_clip_names).to eq "cat.mov - clippy"
end
end
context "when only source_file_name present" do
it "returns source_file_name from confirmation" do
confirmation.source_file_name = "cat.mov"
confirmation.clip_name = nil
expect(subject.source_file_and_clip_names).to eq "cat.mov"
end
end
context "when only clip_name present" do
it "returns clip_name from confirmation" do
confirmation.source_file_name = nil
confirmation.clip_name = "clippy"
expect(subject.source_file_and_clip_names).to eq "clippy"
end
end
context "when source_file_name and clip_name present" do
it "returns empty string" do
confirmation.source_file_name = nil
confirmation.clip_name = ""
expect(subject.source_file_and_clip_names).to eq ""
end
end
end
describe "#timecode_in" do
it "returns timecode_in from confirmation" do
expect(subject.timecode_in).to eq "timecode_in"
end
end
describe "#timecode_out" do
it "returns timecode_out from confirmation" do
expect(subject.timecode_out).to eq "timecode_out"
end
end
describe "#duration" do
it "returns duration from confirmation" do
expect(subject.duration).to eq "duration"
end
end
describe "#confirmation" do
it "returns given confirmation" do
expect(subject.confirmation).to eq confirmation
end
end
describe "#contact_address" do
it "returns address from contact info" do
expect(subject.contact_address).to eq("contact_address")
end
end
end
end
end