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,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