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