kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.6 KiB
86 lines
2.6 KiB
15 years ago
|
require 'spec_helper'
|
||
|
|
||
|
describe "SpreadsheetBuilder" do
|
||
|
before(:each) do
|
||
11 years ago
|
@spreadsheet = OpenProject::XlsExport::SpreadsheetBuilder.new
|
||
15 years ago
|
@sheet = @spreadsheet.send(:raw_sheet)
|
||
|
end
|
||
11 years ago
|
|
||
15 years ago
|
it "should add a single title in the first row" do
|
||
|
@spreadsheet.add_title("A fancy title")
|
||
11 years ago
|
expect(@sheet.last_row_index).to eq(0)
|
||
15 years ago
|
end
|
||
|
|
||
|
it "should add the title complety in the first cell" do
|
||
|
title = "A fancy title"
|
||
|
@spreadsheet.add_title(title)
|
||
11 years ago
|
expect(@sheet.last_row[0]).to eq(title)
|
||
|
expect(@sheet.last_row[1]).to eq(nil)
|
||
15 years ago
|
end
|
||
|
|
||
|
it "should overwrite titles in consecutive calls" do
|
||
|
title = "A fancy title"
|
||
|
@spreadsheet.add_title(title)
|
||
|
@spreadsheet.add_title(title)
|
||
11 years ago
|
expect(@sheet.last_row_index).to eq(0)
|
||
15 years ago
|
end
|
||
11 years ago
|
|
||
15 years ago
|
it "should do some formatting on the title" do
|
||
|
@spreadsheet.add_title("A fancy title")
|
||
11 years ago
|
expect(@sheet.last_row.format(0)).not_to eq(@sheet.last_row.format(1))
|
||
15 years ago
|
end
|
||
11 years ago
|
|
||
15 years ago
|
it "should add empty rows starting in the second line" do
|
||
|
@spreadsheet.add_empty_row
|
||
11 years ago
|
expect(@sheet.last_row_index).to eq(1)
|
||
15 years ago
|
end
|
||
11 years ago
|
|
||
15 years ago
|
it "should add empty rows at the next sequential row" do
|
||
|
@spreadsheet.add_empty_row
|
||
|
first = @sheet.last_row_index
|
||
|
@spreadsheet.add_empty_row
|
||
11 years ago
|
expect(@sheet.last_row_index).to eq(first + 1)
|
||
15 years ago
|
end
|
||
11 years ago
|
|
||
15 years ago
|
it "should add headers in the second line per default" do
|
||
|
@spreadsheet.add_headers((1..3).to_a)
|
||
11 years ago
|
expect(@sheet.last_row_index).to eq(1)
|
||
15 years ago
|
end
|
||
11 years ago
|
|
||
15 years ago
|
it "should allow adding headers in the first line" do
|
||
15 years ago
|
@spreadsheet.add_headers((1..3).to_a, 0)
|
||
11 years ago
|
expect(@sheet.last_row_index).to eq(0)
|
||
15 years ago
|
end
|
||
11 years ago
|
|
||
15 years ago
|
it "should add headers with some formatting" do
|
||
15 years ago
|
@spreadsheet.add_headers([1], 0)
|
||
11 years ago
|
expect(@sheet.last_row.format(0)).not_to eq(@sheet.last_row.format(2))
|
||
15 years ago
|
end
|
||
11 years ago
|
|
||
15 years ago
|
it "should start adding rows in the first line" do
|
||
|
@spreadsheet.add_row((1..3).to_a)
|
||
11 years ago
|
expect(@sheet.last_row_index).to eq(1)
|
||
15 years ago
|
end
|
||
11 years ago
|
|
||
15 years ago
|
it "should add rows sequentially" do
|
||
|
@spreadsheet.add_row((1..3).to_a)
|
||
|
first = @sheet.last_row_index
|
||
|
@spreadsheet.add_row((1..3).to_a)
|
||
11 years ago
|
expect(@sheet.last_row_index).to eq(first + 1)
|
||
15 years ago
|
end
|
||
11 years ago
|
|
||
15 years ago
|
it "should apply no formatting on rows" do
|
||
|
@spreadsheet.add_row([1])
|
||
11 years ago
|
expect(@sheet.last_row.format(0)).to eq(@sheet.last_row.format(1))
|
||
15 years ago
|
end
|
||
11 years ago
|
|
||
15 years ago
|
it "should always use unix newlines" do
|
||
|
@spreadsheet.add_row(["Some text including a windows newline (\r\n)", "And an old-style mac os newline (\r)"])
|
||
|
2.times do |i|
|
||
11 years ago
|
expect(@spreadsheet.send("raw_sheet").last_row[i]).not_to include("\r")
|
||
|
expect(@spreadsheet.send("raw_sheet").last_row[i]).not_to include("\r\n")
|
||
|
expect(@spreadsheet.send("raw_sheet").last_row[i]).to include("\n")
|
||
15 years ago
|
end
|
||
15 years ago
|
end
|
||
11 years ago
|
end
|