diff options
| author | Randy Morgan <[email protected]> | 2012-02-21 08:20:28 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-02-21 08:20:28 +0900 |
| commit | 78f50d06d7ed41f57e87bd2eb7b304b642939306 (patch) | |
| tree | 6cf466e718923262dda7b64b57b4a224fc1a676e | |
| parent | 4e06bb2b6c824ccd6cff287666027619339ad21e (diff) | |
| download | caxlsx-78f50d06d7ed41f57e87bd2eb7b304b642939306.tar.gz caxlsx-78f50d06d7ed41f57e87bd2eb7b304b642939306.zip | |
specs for Jonathan Tron's applyBorder patch.
| -rw-r--r-- | lib/axlsx/stylesheet/styles.rb | 3 | ||||
| -rw-r--r-- | test/stylesheet/tc_styles.rb | 8 |
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb index e8bcdbfb..633fbcad 100644 --- a/lib/axlsx/stylesheet/styles.rb +++ b/lib/axlsx/stylesheet/styles.rb @@ -199,6 +199,7 @@ module Axlsx end borderId = options[:border] || 0 + raise ArgumentError, "Invalid borderId" unless borderId < borders.size fill = if options[:bg_color] @@ -223,8 +224,8 @@ module Axlsx xf = Xf.new(:fillId => fill, :fontId=>fontId, :applyFill=>1, :applyFont=>1, :numFmtId=>numFmtId, :borderId=>borderId, :applyProtection=>applyProtection) - xf.applyBorder = true if borderId > 0 xf.applyNumberFormat = true if xf.numFmtId > 0 + xf.applyBorder = true if borderId > 0 if options[:alignment] xf.alignment = CellAlignment.new(options[:alignment]) diff --git a/test/stylesheet/tc_styles.rb b/test/stylesheet/tc_styles.rb index 15020608..df180b61 100644 --- a/test/stylesheet/tc_styles.rb +++ b/test/stylesheet/tc_styles.rb @@ -42,10 +42,14 @@ class TestStyles < Test::Unit::TestCase assert(xf.alignment.is_a?(Axlsx::CellAlignment), "alignment was created") assert_equal(xf.alignment.horizontal, :left, "horizontal alignment applied") - assert_equal(xf.applyProtection, 1, "protection applied") assert_equal(xf.protection.hidden, true, "hidden protection set") assert_equal(xf.protection.locked, true, "cell locking set") - assert_raise(ArgumentError, "should reject invalid borderId") { @styles.add_style :border => 2 } + assert_raise(ArgumentError, "should reject invalid borderId") { @styles.add_style :border => 2 } + + + assert_equal(xf.applyProtection, 1, "protection applied") + assert_equal(xf.applyBorder, true, "border applied") + assert_equal(xf.applyNumberFormat, true, "border applied") end |
