summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-02-15 02:55:36 -0800
committerRandy Morgan <[email protected]>2012-02-15 02:55:36 -0800
commit41b78ef639c7d3f5f157f478d644e793cef370b4 (patch)
tree0f08388200d622a4c283fa65c6dd0d1c8d1f8212 /test
parente05bb928442aae6e026f3484745f8b99fda64aa2 (diff)
parenta801abe057cc0bc6ddde0a4a80b388b40d8338b9 (diff)
downloadcaxlsx-41b78ef639c7d3f5f157f478d644e793cef370b4.tar.gz
caxlsx-41b78ef639c7d3f5f157f478d644e793cef370b4.zip
Merge pull request #27 from ochko/master
Skip auto fit update or directly set fixed value for column width Ill be making some small changes for readability - but this, sir is great!
Diffstat (limited to 'test')
-rw-r--r--test/workbook/worksheet/tc_worksheet.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb
index e50490d0..0295a64f 100644
--- a/test/workbook/worksheet/tc_worksheet.rb
+++ b/test/workbook/worksheet/tc_worksheet.rb
@@ -143,6 +143,16 @@ class TestWorksheet < Test::Unit::TestCase
assert_equal(@ws.auto_fit_data[0], {:sz=>10,:longest=>"mule", :fixed=>nil}, "adding a row updates auto_fit_data if the product of the string length and font is greater for the column")
end
+ def test_set_fixed_width_column
+ big = @ws.workbook.styles.add_style(:sz=>10)
+
+ @ws.add_row ["mule", "donkey", "horse"], :style=>big, :widths => [20, true, false]
+ assert(@ws.auto_fit_data.size == 3, "a data item for each column")
+ assert_equal({:sz=>11, :fixed=>20, :longest=>"" }, @ws.auto_fit_data[0], "adding a row with fixed width updates :fixed attribute")
+ assert_equal({:sz=>11,:longest=>"", :fixed=>nil}, @ws.auto_fit_data[1], "adding a row with fixed with 'true' doesn't try set auto fit data")
+ assert_equal({:sz=>10,:longest=>"horse", :fixed=>nil}, @ws.auto_fit_data[2], "adding a row with falsy fixed value updates auto_fit_data")
+ end
+
def test_auto_width
assert(@ws.send(:auto_width, {:sz=>11, :longest=>"fisheries"}) > @ws.send(:auto_width, {:sz=>11, :longest=>"fish"}), "longer strings get a longer auto_width at the same font size")