parent
11ed6be091
commit
516dde86e4
@ -1,27 +1,63 @@ |
|||||||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') |
||||||
|
|
||||||
describe OpenProject::PdfExport::TaskboardCard::DocumentGenerator do |
describe OpenProject::PdfExport::TaskboardCard::DocumentGenerator do |
||||||
# let(:pdf) { Prawn::Document.new(:margin => 0) } |
|
||||||
let(:config) { TaskboardCardConfiguration.new({ |
let(:config) { TaskboardCardConfiguration.new({ |
||||||
name: "Default", |
name: "Default", |
||||||
identifier: "default", |
identifier: "default", |
||||||
per_page: 1, |
per_page: 1, |
||||||
page_size: "A4", |
page_size: "A4", |
||||||
orientation: "landscape", |
orientation: "landscape", |
||||||
rows: "rows:\n row1:\n has_border: false\n columns:\n id:\n has_label: false\n font_size: 15\n row1:\n has_border: false\n columns:\n subject:\n has_label: false\n font_size: 15" |
rows: "rows:\n row1:\n has_border: false\n columns:\n subject:\n has_label: false\n font_size: 15\n row2:\n has_border: false\n columns:\n non_existent:\n has_label: false\n font_size: 15\n has_label: true\n render_if_empty: true" |
||||||
})} |
})} |
||||||
let(:work_package) { WorkPackage.new({ |
|
||||||
id: 1234, |
let(:work_package1) { WorkPackage.new({ |
||||||
subject: "Test work package", |
subject: "Work package 1", |
||||||
description: "This is a test work package" |
description: "This is work package 1" |
||||||
|
})} |
||||||
|
|
||||||
|
let(:work_package2) { WorkPackage.new({ |
||||||
|
subject: "Work package 2", |
||||||
|
description: "This is work package 2" |
||||||
})} |
})} |
||||||
|
|
||||||
it 'shows work package subject' do |
describe "Single work package rendering" do |
||||||
work_packages = [work_package] |
before(:each) do |
||||||
generator = OpenProject::PdfExport::TaskboardCard::DocumentGenerator.new(config, work_packages) |
work_packages = [work_package1] |
||||||
|
@generator = OpenProject::PdfExport::TaskboardCard::DocumentGenerator.new(config, work_packages) |
||||||
|
end |
||||||
|
|
||||||
|
it 'shows work package subject' do |
||||||
|
text_analysis = PDF::Inspector::Text.analyze(@generator.render) |
||||||
|
text_analysis.strings.include?('Work package 1').should be_true |
||||||
|
end |
||||||
|
|
||||||
|
it 'shows empty field label' do |
||||||
|
text_analysis = PDF::Inspector::Text.analyze(@generator.render) |
||||||
|
text_analysis.strings.include?('Non existent:-').should be_true |
||||||
|
end |
||||||
|
|
||||||
|
it 'should be 1 page' do |
||||||
|
page_analysis = PDF::Inspector::Page.analyze(@generator.render) |
||||||
|
page_analysis.pages.size.should == 1 |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
describe "Multiple work package rendering" do |
||||||
|
before(:each) do |
||||||
|
work_packages = [work_package1, work_package2] |
||||||
|
@generator = OpenProject::PdfExport::TaskboardCard::DocumentGenerator.new(config, work_packages) |
||||||
|
end |
||||||
|
|
||||||
|
it 'shows work package subject' do |
||||||
|
text = PDF::Inspector::Text.analyze(@generator.render) |
||||||
|
text.strings.include?('Work package 1').should be_true |
||||||
|
text.strings.include?('Work package 2').should be_true |
||||||
|
end |
||||||
|
|
||||||
text = PDF::Inspector::Text.analyze(generator.render) |
it 'should be 2 pages' do |
||||||
text.strings.join.should == 'Test work package' |
page_analysis = PDF::Inspector::Page.analyze(@generator.render) |
||||||
|
page_analysis.pages.size.should == 2 |
||||||
|
end |
||||||
end |
end |
||||||
|
|
||||||
end |
end |
Loading…
Reference in new issue