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,138 @@
require "rails_helper"
module ExcelReports
module AudioReports
RSpec.describe AudioConfirmationData do
let(:audio_confirmation) do
build(:audio_confirmation,
music_type: "Vocal",
music_category: "Feature",
title: "title",
source_file_name: "source_file_name",
)
end
subject { described_class.new(audio_confirmation) }
describe "#music_type" do
it "returns first letter of music_type" do
expect(subject.music_type).to eq "V"
end
context "when music_type nil" do
before :each do
audio_confirmation.music_type = nil
end
it "returns empty string" do
expect(subject.music_type).to eq ""
end
end
end
describe "#music_category" do
it "returns first letter of music_category" do
expect(subject.music_category).to eq "F"
end
context "when music_category nil" do
before :each do
audio_confirmation.music_category = nil
end
it "returns empty string" do
expect(subject.music_category).to eq ""
end
end
end
describe "#title_and_source_file_name" do
it "returns title_and_source_file_name and source filename separated by dash" do
expect(subject.title_and_source_file_name).to eq("title - source_file_name")
end
context "when source filename is blank" do
it "returns title_and_source_file_name alone" do
audio_confirmation.source_file_name = nil
expect(subject.title_and_source_file_name).to eq("title")
end
end
end
describe "#origin" do
context "for library music" do
let(:audio_confirmation) { build(:audio_confirmation, :library) }
it "returns 'Production Library (Non-affiliated)'" do
expect(subject.origin).to eq("Production Library (Non-affiliated)")
end
end
context "for original music" do
let(:audio_confirmation) { build(:audio_confirmation, :original) }
it "returns 'Commissioned'" do
expect(subject.origin).to eq("Commissioned")
end
end
end
describe "#composers_with_split" do
let(:audio_confirmation) { build(:audio_confirmation, composer_info: "John Doe, BMI, 50%") }
it "includes name, affiliation, and percentage split" do
expect(subject.composers_with_split).to eq "John Doe (BMI) 50.0%"
end
context "when there are co-writers " do
let(:audio_confirmation) { build(:audio_confirmation, composer_info: "John Doe, Jane Doe, BMI, 50%") }
it "includes both names" do
expect(subject.composers_with_split).to eq "John Doe, Jane Doe (BMI) 50.0%"
end
end
context "when there are multiple composers" do
let(:audio_confirmation) { build(:audio_confirmation, composer_info: "John Doe, BMI, 50% | Jane Doe, Universal, 50%") }
it "includes both composers separated by a newline" do
expect(subject.composers_with_split).to eq "John Doe (BMI) 50.0%\n Jane Doe (Universal) 50.0%"
end
end
context "when there is a cae number" do
let(:audio_confirmation) { build(:audio_confirmation, composer_info: "John Doe, Jane Doe, BMI, 50%, $cae:abc123 | James Doe, Universal, 50%, $cae:def456") }
it "does not include the cae number" do
expect(subject.composers_with_split).to eq "John Doe, Jane Doe (BMI) 50.0%\n James Doe (Universal) 50.0%"
end
end
end
describe "#composers_cae_numbers" do
let(:audio_confirmation) { build(:audio_confirmation, composer_info: "John Doe, BMI, 50%, $cae:abc123") }
it "includes cae number" do
expect(subject.composers_cae_numbers).to eq("abc123")
end
context "when there are multiple composers" do
let(:audio_confirmation) { build(:audio_confirmation, composer_info: "John Doe, BMI, 50%, $cae:abc123 | Jane Doe, Universal, 50%, $cae:def456") }
it "includes all cae numbers separated by a newline" do
expect(subject.composers_cae_numbers).to eq("abc123\ndef456")
end
end
context "when cae numbers are not present" do
let(:audio_confirmation) { build(:audio_confirmation, composer_info: "John Doe, BMI, 50%") }
it "returns an empty string" do
expect(subject.composers_cae_numbers).to be_empty
end
end
end
end
end
end

View File

@@ -0,0 +1,69 @@
require "rails_helper"
module ExcelReports
module AudioReports
RSpec.describe BrayInnovationGroupMusicCueReport do
let(:video) { create(:video) }
subject { described_class.new(video) }
describe "#to_xls" do
it "builds report" do
package = instance_double(Axlsx::Package)
workbook = instance_double(Axlsx::Workbook)
stream = double(:stream, read: "my-report")
allow(Axlsx::Package).to receive(:new).and_return(package)
allow(package).to receive(:workbook).and_return(workbook)
allow(package).to receive(:to_stream).and_return(stream)
allow(BrayInnovationGroupMusicCueSheet).to receive(:build)
create(:audio_confirmation, :library, video: video)
create(:audio_confirmation, :original, video: video)
result = subject.to_xls
expect(package).to have_received(:to_stream)
expect(BrayInnovationGroupMusicCueSheet).to have_received(:build).with(
workbook,
[instance_of(AudioConfirmationData), instance_of(AudioConfirmationData)],
instance_of(BrayInnovationGroupMusicCueHeaderData)
)
expect(stream).to have_received(:read)
expect(result).to eq("my-report")
end
it "sorts audio data by ascending timecode_in" do
package = instance_double(Axlsx::Package)
workbook = instance_double(Axlsx::Workbook)
stream = double(:stream, read: "my-report")
allow(Axlsx::Package).to receive(:new).and_return(package)
allow(package).to receive(:workbook).and_return(workbook)
allow(package).to receive(:to_stream).and_return(stream)
allow(BrayInnovationGroupMusicCueSheet).to receive(:build)
earlier = create(:audio_confirmation, :original, video: video, timecode_in: "00:00:00:02")
earliest = create(:audio_confirmation, :library, video: video, timecode_in: "00:00:00:01")
early = create(:audio_confirmation, :library, video: video, timecode_in: "00:00:00:03")
subject.to_xls
expect(BrayInnovationGroupMusicCueSheet).to have_received(:build).with(
workbook,
[
AudioConfirmationData.new(earliest),
AudioConfirmationData.new(earlier),
AudioConfirmationData.new(early),
],
instance_of(BrayInnovationGroupMusicCueHeaderData)
)
end
end
describe "#filename" do
it "returns video filename with 'big-cue-sheet'" do
expect(subject.filename).to eq "video_file-mp4_big-cue-sheet.xlsx"
end
end
end
end
end

View File

@@ -0,0 +1,176 @@
require "rails_helper"
module ExcelReports
module AudioReports
RSpec.describe BrayInnovationGroupMusicCueSheet do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
subject { described_class.new(workbook) }
it_behaves_like "a worksheet"
describe "#title" do
it "returns 'BiG Music Cue Sheet'" do
expect(subject.title).to eq "BiG Music Cue Sheet"
end
end
describe "#fill_content" do
it "adds headers and data to given sheet" do
sheet = instance_double(Axlsx::Worksheet)
allow(sheet).to receive(:add_row)
video = create(:video,
name: "video name",
project: build(:project,
producer_name: "company name",
producer_address: "company address",
),
)
original_confirmation = create(:audio_confirmation, :original,
video: video,
title: "title_1",
source_file_name: "filename_1",
timecode_in: "01:00:00:00",
timecode_out: "01:05:00:00",
duration: "00:05:00",
music_type: "Vocal",
music_category: "Background",
composer_info: "composer1, affiliation, 50%|composer2, affiliation, 50%",
publisher_info: "publisher1, affiliation, 50%|publisher2, affiliation, 50%",
)
library_confirmation = create(:audio_confirmation, :library,
video: video,
title: "title_2",
source_file_name: "filename_2",
timecode_in: "01:00:00:00",
timecode_out: "01:05:00:00",
duration: "00:05:00",
music_type: "Vocal",
music_category: "Background",
composer_info: "composer1, affiliation, 50%|composer2, affiliation, 50%",
publisher_info: "publisher1, affiliation, 50%|publisher2, affiliation, 50%",
)
header_data = BrayInnovationGroupMusicCueHeaderData.new(video)
data = [AudioConfirmationData.new(original_confirmation), AudioConfirmationData.new(library_confirmation)]
described_class.new(workbook, data, header_data).fill_content(sheet)
expect(sheet).to have_received(:add_row).with(["TITLE", "video name"])
expect(sheet).to have_received(:add_row).with(["COMPANY NAME", "company name"])
expect(sheet).to have_received(:add_row).with(["ADDRESS", "company address"])
expect(sheet).to have_received(:add_row).with(["LENGTH", ""])
expect(sheet).to have_received(:add_row).with(["TYPE", ""])
expect(sheet).to have_received(:add_row).with(no_args)
expect(sheet).to have_received(:add_row).with([
"Cue #",
"Cue Title",
"Composer(s)/Affiliation",
"%",
"Publisher(s)/Affiliation",
"%",
"Use",
"",
"In Time",
"Out Time",
"Duration",
])
expect(sheet).to have_received(:add_row).with([
"",
"",
"",
"",
"",
"",
"I = Instr.\nV = Vocal",
"B = Bckgrnd\nF = Feature\nT = Theme",
"",
"",
"",
])
expect(sheet).to have_received(:add_row).with([
"",
"title_1 - filename_1",
"composer1 (affiliation)\ncomposer2 (affiliation)",
"50.0\n50.0",
"publisher1 (affiliation)\npublisher2 (affiliation)",
"50.0\n50.0",
"V",
"B",
"01:00:00:00",
"01:05:00:00",
"00:05:00",
])
expect(sheet).to have_received(:add_row).with([
"",
"title_2 - filename_2",
"composer1 (affiliation)\ncomposer2 (affiliation)",
"50.0\n50.0",
"publisher1 (affiliation)\npublisher2 (affiliation)",
"50.0\n50.0",
"V",
"B",
"01:00:00:00",
"01:05:00:00",
"00:05:00",
])
end
end
describe "#format" do
it "sets column widths" do
sheet = instance_double(Axlsx::Worksheet)
allow(sheet).to receive(:column_widths)
allow(sheet).to receive(:merge_cells)
subject.format(sheet)
expect(sheet).to have_received(:column_widths).with(15, 40, 20, 10, 20, 10, 20, 20, 15, 15, 15)
expect(sheet).to have_received(:merge_cells).with("G7:H7")
end
end
describe "#style" do
it "sets sheet style" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
expect(sheet).to receive(:add_style).with("A1:A5",
{
bg_color: "97CBFC",
b: true,
border: { :style => :thick, :color => "000000" },
alignment: { :horizontal => :center, :wrap_text => true },
sz: 12,
}
)
expect(sheet).to receive(:add_style).with(
"B1:B5",
{
border: { :style => :thick, :color => "000000" },
alignment: { :wrap_text => true, :horizontal => :left },
sz: 10,
}
)
expect(sheet).to receive(:add_style).with(
"A7:K7",
{
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).at_least(1).with("A9:K10",
{
border: { style: :thick, color: "000000" },
alignment: { wrap_text: true },
sz: 10
}
)
described_class.new(workbook, ["data1", "data2"]).style(sheet)
end
end
end
end
end

View File

@@ -0,0 +1,69 @@
require "rails_helper"
module ExcelReports
module AudioReports
RSpec.describe DiscoveryMusicCueReport do
let(:video) { create(:video) }
subject { described_class.new(video) }
describe "#to_xls" do
it "builds report" do
package = instance_double(Axlsx::Package)
workbook = instance_double(Axlsx::Workbook)
stream = double(:stream, read: "my-report")
allow(Axlsx::Package).to receive(:new).and_return(package)
allow(package).to receive(:workbook).and_return(workbook)
allow(package).to receive(:to_stream).and_return(stream)
allow(DiscoveryMusicCueSheet).to receive(:build)
create(:audio_confirmation, :original, video: video)
create(:audio_confirmation, :library, video: video)
result = subject.to_xls
expect(package).to have_received(:to_stream)
expect(DiscoveryMusicCueSheet).to have_received(:build).with(
workbook,
[instance_of(AudioConfirmationData), instance_of(AudioConfirmationData)],
instance_of(DiscoveryMusicCueHeaderData)
)
expect(stream).to have_received(:read)
expect(result).to eq("my-report")
end
it "sorts audio data by ascending timecode_in" do
package = instance_double(Axlsx::Package)
workbook = instance_double(Axlsx::Workbook)
stream = double(:stream, read: "my-report")
allow(Axlsx::Package).to receive(:new).and_return(package)
allow(package).to receive(:workbook).and_return(workbook)
allow(package).to receive(:to_stream).and_return(stream)
allow(DiscoveryMusicCueSheet).to receive(:build)
earlier = create(:audio_confirmation, :original, video: video, timecode_in: "00:00:00:02")
earliest = create(:audio_confirmation, :library, video: video, timecode_in: "00:00:00:01")
early = create(:audio_confirmation, :library, video: video, timecode_in: "00:00:00:03")
subject.to_xls
expect(DiscoveryMusicCueSheet).to have_received(:build).with(
workbook,
[
AudioConfirmationData.new(earliest),
AudioConfirmationData.new(earlier),
AudioConfirmationData.new(early),
],
instance_of(DiscoveryMusicCueHeaderData)
)
end
end
describe "#filename" do
it "returns video filename with 'discovery-cue-sheet'" do
expect(subject.filename).to eq "video_file-mp4_discovery-cue-sheet.xlsx"
end
end
end
end
end

View File

@@ -0,0 +1,195 @@
require "rails_helper"
module ExcelReports
module AudioReports
RSpec.describe DiscoveryMusicCueSheet do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
subject { described_class.new(workbook) }
it_behaves_like "a worksheet"
describe "#title" do
it "returns 'Discovery Music Cue Sheet'" do
expect(subject.title).to eq "Discovery Music Cue Sheet"
end
end
describe "#fill_content" do
it "adds headers and data to given sheet for both types of audio confirmations" do
sheet = instance_double(Axlsx::Worksheet)
allow(sheet).to receive(:add_row)
project = create(:project, client_name: "client_name", producer_name: "producer_name")
video = create(:video, project: project, number: 42, name: "video_name")
header_data = DiscoveryMusicCueHeaderData.new(video)
data = [
AudioConfirmationData.new(
build(:audio_confirmation,
timecode_in: "timecode_in_1",
title: "title_1",
catalog: "catalog_1",
duration: "duration_1",
music_type: "music_type_1",
music_category: "music_category_1",
composer_info: "composer_info_1",
publisher_info: "publisher_info_1",
source_file_name: "source_file_name_1",
)
),
AudioConfirmationData.new(
build(:audio_confirmation,
timecode_in: "timecode_in_2",
title: "title_2",
catalog: "catalog_2",
duration: "duration_2",
music_type: "music_type_2",
music_category: "music_category_2",
composer_info: "composer_info_2",
publisher_info: "publisher_info_2",
source_file_name: "source_file_name_2",
)
)
]
described_class.new(workbook, data, header_data).fill_content(sheet)
expect(sheet).to have_received(:add_row).with(["Original Production Title", "video_name", "Original Series Title", "", "Broadcaster", ""])
expect(sheet).to have_received(:add_row).with(["Alternative Production Title", "", "Alternative Series Title", "", "Production Company", "producer_name"])
expect(sheet).to have_received(:add_row).with(["Local Production Title", "", "Local Series Title", "", "", ""])
expect(sheet).to have_received(:add_row).with(["Working Production Title", "", "Working Series Title", "", "Production Number", ""])
expect(sheet).to have_received(:add_row).with(["Version Production Title", "", "Version Series Title", "", "Director", ""])
expect(sheet).to have_received(:add_row).with(["Episode No.", "42", "Season No.", "", "Production Parent Identifier", ""])
expect(sheet).to have_received(:add_row).with(["Year", "", "Country", "", "Soundmouse Legacy Identifier", ""])
expect(sheet).to have_received(:add_row).with(["Duration", "", "Type", "", "Production ID", ""])
expect(sheet).to have_received(:add_row).with(["First Transmission", "", "Source", ""])
expect(sheet).to have_received(:add_row).with(["Product Name", ""])
expect(sheet).to have_received(:add_row).with(["Client Name", "client_name"])
expect(sheet).to have_received(:add_row).with(["Narrative", ""])
expect(sheet).to have_received(:add_row).with(["End Line", ""])
expect(sheet).to have_received(:add_row).with(["Clock Number", ""])
expect(sheet).to have_received(:add_row).with(["ISAN", ""])
expect(sheet).to have_received(:add_row).with(no_args)
expect(sheet).to have_received(:add_row).with([
"No.",
"Timecode",
"Title",
"Music Origin",
"Use (Theme/Description)",
"Interested Parties",
"Identifiers",
"Duration",
])
expect(sheet).to have_received(:add_row).with([
1,
"timecode_in_1",
"title_1 - source_file_name_1",
"catalog_1",
"music_type_1 music_category_1",
"Composers:\ncomposer_info_1\nPublishers:\npublisher_info_1",
"",
"duration_1",
])
expect(sheet).to have_received(:add_row).with([
2,
"timecode_in_2",
"title_2 - source_file_name_2",
"catalog_2",
"music_type_2 music_category_2",
"Composers:\ncomposer_info_2\nPublishers:\npublisher_info_2",
"",
"duration_2",
])
end
end
describe "#format" do
it "sets column widths" do
sheet = instance_double(Axlsx::Worksheet)
allow(sheet).to receive(:column_widths)
subject.format(sheet)
expect(sheet).to have_received(:column_widths).with(20, 20, 40, 20, 20, 20, 20, 20)
end
end
describe "#style" do
it "sets sheet style" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
expect(sheet).to receive(:add_style).with("A1:A15",
{
bg_color: "97CBFC",
b: true,
border: { :style => :thick, :color => "000000" },
alignment: { :horizontal => :center, :wrap_text => true },
sz: 12,
}
)
expect(sheet).to receive(:add_style).with("C1:C9",
{
bg_color: "97CBFC",
b: true,
border: { :style => :thick, :color => "000000" },
alignment: { :horizontal => :center, :wrap_text => true },
sz: 12,
}
)
expect(sheet).to receive(:add_style).with("E1:E8",
{
bg_color: "97CBFC",
b: true,
border: { :style => :thick, :color => "000000" },
alignment: { :horizontal => :center, :wrap_text => true },
sz: 12,
}
)
expect(sheet).to receive(:add_style).with(
"B1:B15",
{
border: { :style => :thick, :color => "000000" },
alignment: { :wrap_text => true, :horizontal => :left },
sz: 10,
}
)
expect(sheet).to receive(:add_style).with(
"D1:D9",
{
border: { :style => :thick, :color => "000000" },
alignment: { :wrap_text => true, :horizontal => :left },
sz: 10,
}
)
expect(sheet).to receive(:add_style).with(
"F1:F8",
{
border: { :style => :thick, :color => "000000" },
alignment: { :wrap_text => true, :horizontal => :left },
sz: 10,
}
)
expect(sheet).to receive(:add_style).with(
"A17:H17",
{
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).at_least(1).with(
"A18:H19",
{
border: { style: :thick, color: "000000" },
alignment: { wrap_text: true },
sz: 10
}
)
described_class.new(workbook, ["data1", "data2"]).style(sheet)
end
end
end
end
end

View File

@@ -0,0 +1,67 @@
require "rails_helper"
module ExcelReports
module AudioReports
RSpec.describe NatGeoMusicCueSheet do
let(:video) { create(:video) }
subject { described_class.new(video) }
describe "#to_xls" do
it "builds report" do
package = instance_double(Axlsx::Package)
workbook = instance_double(Axlsx::Workbook)
stream = double(:stream, read: "my-report")
allow(Axlsx::Package).to receive(:new).and_return(package)
allow(package).to receive(:workbook).and_return(workbook)
allow(package).to receive(:to_stream).and_return(stream)
allow(NatGeoMusicCueSheets::MainSheet).to receive(:build)
create(:audio_confirmation, :original, video: video)
create(:audio_confirmation, :library, video: video)
result = subject.to_xls
expect(package).to have_received(:to_stream)
expect(NatGeoMusicCueSheets::MainSheet).to have_received(:build).with(
workbook,
[instance_of(AudioConfirmationData), instance_of(AudioConfirmationData)],
)
expect(stream).to have_received(:read)
expect(result).to eq("my-report")
end
it "sorts audio data by ascending timecode_in" do
package = instance_double(Axlsx::Package)
workbook = instance_double(Axlsx::Workbook)
stream = double(:stream, read: "my-report")
allow(Axlsx::Package).to receive(:new).and_return(package)
allow(package).to receive(:workbook).and_return(workbook)
allow(package).to receive(:to_stream).and_return(stream)
allow(NatGeoMusicCueSheets::MainSheet).to receive(:build)
earlier = create(:audio_confirmation, :original, video: video, timecode_in: "00:00:00:02")
earliest = create(:audio_confirmation, :library, video: video, timecode_in: "00:00:00:01")
early = create(:audio_confirmation, :library, video: video, timecode_in: "00:00:00:03")
subject.to_xls
expect(NatGeoMusicCueSheets::MainSheet).to have_received(:build).with(
workbook,
[
AudioConfirmationData.new(earliest),
AudioConfirmationData.new(earlier),
AudioConfirmationData.new(early),
]
)
end
end
describe "#filename" do
it "returns video filename with 'discovery-cue-sheet'" do
expect(subject.filename).to eq "video_file-mp4_music-cue-sheet.xlsx"
end
end
end
end
end

View File

@@ -0,0 +1,129 @@
require "rails_helper"
module ExcelReports
module AudioReports
module NatGeoMusicCueSheets
RSpec.describe MainSheet 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 "Nat Geo Music Cue Sheet"
end
end
describe "#fill_content" do
it "adds headers and data to given sheet for both types of audio confirmations" do
sheet = instance_double(Axlsx::Worksheet)
allow(sheet).to receive(:add_row)
video = create(:video)
header_data = video
data = [
AudioConfirmationData.new(
build(:audio_confirmation,
:library,
timecode_in: "timecode_in_1",
timecode_out: "timecode_out_1",
title: "title_1",
catalog: "catalog_1",
duration: "00:02:30",
music_type: "music_type_1",
music_category: "music_category_1",
composer_info: "composer1, affiliation, 50%|composer2, affiliation, 50%",
publisher_info: "publisher1, affiliation, 50%|publisher2, affiliation, 50%",
source_file_name: "source_file_name_1",
)
),
AudioConfirmationData.new(
build(:audio_confirmation,
:original,
timecode_in: "timecode_in_2",
timecode_out: "timecode_out_2",
title: "title_2",
catalog: "catalog_2",
duration: "00:03:50",
music_type: "music_type_2",
music_category: "music_category_2",
composer_info: "composer1, affiliation, 50%|composer2, affiliation, 50%",
publisher_info: "publisher1, affiliation, 50%|publisher2, affiliation, 50%",
source_file_name: "source_file_name_2",
)
)
]
described_class.new(workbook, data, header_data).fill_content(sheet)
expect(sheet).to have_received(:add_row).with([
"No.",
"Title",
"In",
"Out",
"Composer",
"Publisher",
"Record Label / Library",
"Music Origin",
"Use",
"Duration",
])
expect(sheet).to have_received(:add_row).with([
1,
"title_1 - source_file_name_1",
"timecode_in_1",
"timecode_out_1",
"composer1 (affiliation) 50.0%\ncomposer2 (affiliation) 50.0%",
"publisher1 (affiliation) 50.0%\npublisher2 (affiliation) 50.0%",
"catalog_1",
"Production Library (Non-affiliated)",
"music_type_1 music_category_1",
"00:02:30",
])
expect(sheet).to have_received(:add_row).with([
2,
"title_2 - source_file_name_2",
"timecode_in_2",
"timecode_out_2",
"composer1 (affiliation) 50.0%\ncomposer2 (affiliation) 50.0%",
"publisher1 (affiliation) 50.0%\npublisher2 (affiliation) 50.0%",
"catalog_2",
"Commissioned",
"music_type_2 music_category_2",
"00:03:50",
])
expect(sheet).to have_received(:add_row).with([
"", "", "", "", "", "", "", "", "Total Music Duration:", "00:06:20"
])
end
end
describe "#format" do
it "sets column widths and merges cells" do
sheet = instance_double(Axlsx::Worksheet)
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)
described_class.new(workbook, ["data1", "data2"]).style(sheet)
expect(sheet).to have_received(:add_style).at_least(1).times
end
end
end
end
end
end

View File

@@ -0,0 +1,87 @@
require "rails_helper"
module ExcelReports
module AudioReports
RSpec.describe NatGeoOriginalMusicLog do
let(:video) { create(:video) }
subject { described_class.new(video) }
describe "#to_xls" do
it "builds report" do
package = instance_double(Axlsx::Package)
workbook = instance_double(Axlsx::Workbook)
stream = double(:stream, read: "my-report")
allow(Axlsx::Package).to receive(:new).and_return(package)
allow(package).to receive(:workbook).and_return(workbook)
allow(package).to receive(:to_stream).and_return(stream)
allow(NatGeoOriginalMusicLogs::MainSheet).to receive(:build)
create(:audio_confirmation, :original, video: video)
create(:audio_confirmation, :original, video: video)
result = subject.to_xls
expect(package).to have_received(:to_stream)
expect(NatGeoOriginalMusicLogs::MainSheet).to have_received(:build).with(
workbook,
[instance_of(AudioConfirmationData), instance_of(AudioConfirmationData)],
)
expect(stream).to have_received(:read)
expect(result).to eq("my-report")
end
it "sorts audio data by ascending timecode_in" do
package = instance_double(Axlsx::Package)
workbook = instance_double(Axlsx::Workbook)
stream = double(:stream, read: "my-report")
allow(Axlsx::Package).to receive(:new).and_return(package)
allow(package).to receive(:workbook).and_return(workbook)
allow(package).to receive(:to_stream).and_return(stream)
allow(NatGeoOriginalMusicLogs::MainSheet).to receive(:build)
earlier = create(:audio_confirmation, :original, video: video, timecode_in: "00:00:00:02")
earliest = create(:audio_confirmation, :original, video: video, timecode_in: "00:00:00:01")
early = create(:audio_confirmation, :original, video: video, timecode_in: "00:00:00:03")
subject.to_xls
expect(NatGeoOriginalMusicLogs::MainSheet).to have_received(:build).with(
workbook,
[
AudioConfirmationData.new(earliest),
AudioConfirmationData.new(earlier),
AudioConfirmationData.new(early),
]
)
end
it "only includes original music" do
package = instance_double(Axlsx::Package)
workbook = instance_double(Axlsx::Workbook)
stream = double(:stream, read: "my-report")
allow(Axlsx::Package).to receive(:new).and_return(package)
allow(package).to receive(:workbook).and_return(workbook)
allow(package).to receive(:to_stream).and_return(stream)
allow(NatGeoOriginalMusicLogs::MainSheet).to receive(:build)
original = create(:audio_confirmation, :original, video: video)
library = create(:audio_confirmation, :library, video: video)
subject.to_xls
expect(NatGeoOriginalMusicLogs::MainSheet).to have_received(:build).with(
workbook,
[AudioConfirmationData.new(original)]
)
end
end
describe "#filename" do
it "returns video filename with 'discovery-cue-sheet'" do
expect(subject.filename).to eq "video_file-mp4_original-music-log.xlsx"
end
end
end
end
end

View File

@@ -0,0 +1,85 @@
require "rails_helper"
module ExcelReports
module AudioReports
module NatGeoOriginalMusicLogs
RSpec.describe MainSheet 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 "Nat Geo Original Music Log"
end
end
describe "#fill_content" do
it "adds headers and data to given sheet for both types of audio confirmations" do
sheet = instance_double(Axlsx::Worksheet)
allow(sheet).to receive(:add_row)
allow(BigMediaTime).to receive(:time_zone_now).and_return(DateTime.new(2019,10,9))
video = create(:video)
header_data = video
data = [
AudioConfirmationData.new(
build(:audio_confirmation,
:original,
title: "title_1",
composer_info: "composer1a, composer1b, affiliation, 50%, $cae:cae123|composer2, affiliation, 50%, $cae:cae456",
publisher_info: "publisher1, affiliation, 50%|publisher2, affiliation, 50%",
source_file_name: "source_file_name_1",
)
),
]
described_class.new(workbook, data, header_data).fill_content(sheet)
expect(sheet).to have_received(:add_row).with([
"10/09/19", "", "", ""
])
expect(sheet).to have_received(:add_row).with([
"CUE TITLE",
"COMPOSER(S), % SPLIT & PRO",
"COMPOSER CAE/IPI#",
"PUBLISHER(S), % SPLIT & PRO",
])
expect(sheet).to have_received(:add_row).with([
"title_1 - source_file_name_1",
"composer1a, composer1b (affiliation) 50.0%\ncomposer2 (affiliation) 50.0%",
"cae123\ncae456",
"publisher1 (affiliation) 50.0%\npublisher2 (affiliation) 50.0%",
])
end
end
describe "#format" do
it "sets column widths and merge cells" do
sheet = instance_double(Axlsx::Worksheet)
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)
described_class.new(workbook, ["data1", "data2"]).style(sheet)
expect(sheet).to have_received(:add_style).at_least(1).times
end
end
end
end
end
end

View File

@@ -0,0 +1,91 @@
require 'rails_helper'
module ExcelReports
module GraphicReports
RSpec.describe DiscoveryGfxCueList do
let(:project) { create(:project) }
describe '#to_xls' do
it 'builds xls file' do
graphics_element = create(:graphics_element)
video = create(:video, graphics_elements: [graphics_element], project: project)
package = double(:package)
workbook = double(:workbook)
stream = double(:stream)
allow(Axlsx::Package).to receive(:new).and_return(package)
allow(package).to receive(:workbook).and_return(workbook)
expect(DiscoveryGfxCueLists::TextedElementsSheet).to receive(:build).with(
workbook,
[
DiscoveryGfxCueList::GraphicsElementsData.new(
"some text",
nil,
nil,
nil,
)
],
DiscoveryGfxCueList::GraphicsElementsHeaderData.new(
nil,
nil,
"My Client",
"My Team",
)
)
expect(package).to receive(:to_stream).and_return(stream)
expect(stream).to receive(:read)
described_class.new(video).to_xls
end
it 'sorts the element data by timecode' do
graphics_elements = [
build(:graphics_element, timecode_in: "00:00:10:00"),
build(:graphics_element, timecode_in: "00:00:05:00"),
build(:graphics_element, timecode_in: nil )
]
video = create(:video, graphics_elements: graphics_elements, project: project)
package = double(:package)
workbook = double(:workbook)
stream = double(:stream)
allow(Axlsx::Package).to receive(:new).and_return(package)
allow(package).to receive(:workbook).and_return(workbook)
allow(package).to receive(:to_stream).and_return(stream)
allow(stream).to receive(:read)
expect(DiscoveryGfxCueLists::TextedElementsSheet).to receive(:build).with(
workbook,
[
DiscoveryGfxCueList::GraphicsElementsData.new(
"some text",
"00:00:05:00",
nil,
nil,
),
DiscoveryGfxCueList::GraphicsElementsData.new(
"some text",
"00:00:10:00",
nil,
nil,
),
DiscoveryGfxCueList::GraphicsElementsData.new(
"some text",
nil,
nil,
nil,
),
],
DiscoveryGfxCueList::GraphicsElementsHeaderData.new(
nil,
nil,
"My Client",
"My Team",
)
)
described_class.new(video).to_xls
end
end
end
end
end

View File

@@ -0,0 +1,73 @@
require "rails_helper"
module ExcelReports
module GraphicReports
module DiscoveryGfxCueLists
RSpec.describe TextedElementsSheet 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 'Texted Elements List'" do
expect(described_class.new(workbook).title).to eq "Texted Elements List"
end
end
describe "#format" do
it "sets sheet column widths to 60, 20, 20" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
expect(sheet).to receive(:column_widths).with(60, 20, 20)
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: 12 })
expect(sheet).to receive(:add_style).with(
"A9:D9",
{
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:A7",
{
bg_color: "97CBFC",
b: true,
border: { :style => :thick, :color => "000000" },
alignment: { :horizontal => :center, :wrap_text => true },
sz: 12,
}
)
expect(sheet).to receive(:add_style).with(
"B3:B7",
{
border: { :style => :thick, :color => "000000" },
alignment: { :wrap_text => true, :horizontal => :left },
sz: 10,
}
)
expect(sheet).to receive(:add_style).at_least(1).with("A10:D11",
{
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,53 @@
require 'rails_helper'
module ExcelReports
module GraphicReports
RSpec.describe NatGeoTextGraphicsLog do
let(:project) { create(:project) }
describe '#to_xls' do
it 'builds xls file' do
graphics_element = create(:graphics_element)
video = create(:video, graphics_elements: [graphics_element], project: project)
package = double(:package)
workbook = double(:workbook)
stream = double(:stream)
allow(Axlsx::Package).to receive(:new).and_return(package)
allow(package).to receive(:workbook).and_return(workbook)
expect(NatGeoTextGraphicsLogs::InternalProgramGfxLogSheet).to receive(:build).with(
workbook,
[graphics_element],
video,
)
expect(package).to receive(:to_stream).and_return(stream)
expect(stream).to receive(:read)
described_class.new(video).to_xls
end
it 'sorts the element data by timecode' do
graphics_elements = [
build(:graphics_element, timecode_in: "00:00:10:00"),
build(:graphics_element, timecode_in: "00:00:05:00"),
build(:graphics_element, timecode_in: nil )
]
video = create(:video, graphics_elements: graphics_elements, project: project)
package = double(:package)
workbook = double(:workbook)
stream = double(:stream)
allow(Axlsx::Package).to receive(:new).and_return(package)
allow(package).to receive(:workbook).and_return(workbook)
allow(package).to receive(:to_stream).and_return(stream)
allow(stream).to receive(:read)
expect(NatGeoTextGraphicsLogs::InternalProgramGfxLogSheet).to receive(:build).with(
workbook, [graphics_elements.second, graphics_elements.first, graphics_elements.last], video,
)
described_class.new(video).to_xls
end
end
end
end
end

View File

@@ -0,0 +1,66 @@
require "rails_helper"
module ExcelReports
module GraphicReports
module NatGeoTextGraphicsLogs
RSpec.describe InternalProgramGfxLogSheet do
let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }
let(:video) { build(:video, name: "My Video", number: 10) }
let(:graphics_element) do
build(:graphics_element,
graphic_type: "Logo",text: "Some Text",
timecode_in: "00:00:05:00", timecode_out: "00:00:10:00")
end
subject { described_class.new(workbook, [graphics_element], video) }
it_behaves_like "a worksheet"
describe "#title" do
it "returns the title of the sheet" do
expect(subject.title).to eq "Internal Program GFX Log"
end
end
describe "#fill_content" do
it "adds content from the data" do
sheet = instance_double(Axlsx::Worksheet, :sheet)
allow(sheet).to receive(:add_row)
allow(BigMediaTime).to receive(:time_zone_now).and_return(Date.new(2019,10,4))
subject.fill_content(sheet)
expect(sheet).to have_received(:add_row).with(["", "Episode Title:", "My Video", "", "", "", "",])
expect(sheet).to have_received(:add_row).with(["", "Episode Number:", "10", "", "", "", "",])
expect(sheet).to have_received(:add_row).with(["", "Date:", "10/04/19", "", "", "", "",])
expect(sheet).to have_received(:add_row).with(["Logo", "Some Text", "00:00:05:00", "00:00:10:00", "", "", "",])
end
end
describe "#format" do
it "sets sheet 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,23 @@
require "rails_helper"
module ExcelReports
module IssuesAndConcernsReports
RSpec.describe IssuesAndConcernsReport do
let(:video) { create(:video) }
subject { described_class.new(video) }
describe "#to_xls" do
it "returns xls file" do
expect(subject.to_xls).not_to be_nil
end
end
describe "#filename" do
it "return 'video_file-mp4_issues-and-concerns.xlsx'" do
expect(subject.filename).to eq "video_file-mp4_issues-and-concerns.xlsx"
end
end
end
end
end

View File

@@ -0,0 +1,116 @@
require "rails_helper"
module ExcelReports
module IssuesAndConcernsReports
RSpec.describe IssuesAndConcernsWorksheet 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 'Issues and Concerns Report'" do
expect(described_class.new(workbook).title).to eq "Issues and Concerns Report"
end
end
describe "#fill_content" do
it "adds content from acquired media release" do
presenter = instance_double(
IssuesAndConcernsReportPresenter,
project_name: "Broadcast across the nation",
video_name: "The News",
date_of_report: "Today",
unreleased_appearances: [
instance_double(UnreleasedAppearance,
timecode_in: "timecode_in",
timecode_out: "timecode_out",
channel: "channel",
source_file_name: "source_file_name",
clip_name: "clip_name",
note_text: "Great notes",
)],
)
sheet = instance_double(Axlsx::Worksheet, :sheet)
expect(sheet).to receive(:add_row).with(["ISSUES AND CONCERNS REPORT"])
expect(sheet).to receive(:add_row).with(["Project Name", "Broadcast across the nation"])
expect(sheet).to receive(:add_row).with(["Video Name", "The News"])
expect(sheet).to receive(:add_row).with(["Date of Report", "Today"])
expect(sheet).to receive(:add_row).with([])
expect(sheet).to receive(:add_row).with(["Track", "TC In", "TC Out", "Clip Name", "Source File Name", "Notes"])
expect(sheet).to receive(:add_row).with(["channel", "timecode_in", "timecode_out", "clip_name", "source_file_name", "Great notes"])
described_class.new(workbook, presenter).fill_content(sheet)
end
end
describe "#format" do
let(:sheet) { instance_double(Axlsx::Worksheet, :sheet) }
before :each do
allow(sheet).to receive(:column_widths)
end
it "sets sheet column widths to 15, 15, 15, 15, 15, 50" do
expect(sheet).to receive(:column_widths).with(15, 15, 15, 15, 15, 50)
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:A4",
{
bg_color: "97CBFC",
b: true,
border: { :style => :thick, :color => "000000" },
alignment: { :horizontal => :center, :wrap_text => true },
sz: 12,
}
)
expect(sheet).to receive(:add_style).with(
"B2:B4",
{
border: { :style => :thick, :color => "000000" },
alignment: { :wrap_text => true, :horizontal => :left },
sz: 10,
}
)
expect(sheet).to receive(:add_style).with(
"A6:F6",
{
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).at_least(1).with(
"A7:F8",
{
border: { style: :thick, color: "000000" },
alignment: { wrap_text: true },
sz: 10
}
)
presenter = instance_double(
IssuesAndConcernsReportPresenter,
unreleased_appearances: [
instance_double(UnreleasedAppearance, timecode_in: "yesterday", notes: "Great notes"),
instance_double(UnreleasedAppearance, timecode_in: "yesterday", notes: "Great notes"),
],
)
described_class.new(workbook, presenter).style(sheet)
end
end
end
end
end

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