diff options
| author | Randy Morgan (@morgan_randy) <[email protected]> | 2013-08-16 20:20:38 -0700 |
|---|---|---|
| committer | Randy Morgan (@morgan_randy) <[email protected]> | 2013-08-16 20:20:38 -0700 |
| commit | 6b865617a3305d780c51cece8f11dbe84f9e0a30 (patch) | |
| tree | 9cded59450a001b8cd1ecc7c542cf1963a0c36a5 | |
| parent | 11c532c718e11bea419b3dcb05d9ff8b351e6db5 (diff) | |
| parent | 6661350bcdd074b6bbc4cf277d65ef5856cb22ac (diff) | |
| download | caxlsx-6b865617a3305d780c51cece8f11dbe84f9e0a30.tar.gz caxlsx-6b865617a3305d780c51cece8f11dbe84f9e0a30.zip | |
Merge pull request #227 from misfo/color-rgb-setter-mutates-its-argument
Color#rgb= mutates its argument
| -rw-r--r-- | lib/axlsx/stylesheet/color.rb | 2 | ||||
| -rw-r--r-- | test/stylesheet/tc_color.rb | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/axlsx/stylesheet/color.rb b/lib/axlsx/stylesheet/color.rb index 744e63d5..e736af7f 100644 --- a/lib/axlsx/stylesheet/color.rb +++ b/lib/axlsx/stylesheet/color.rb @@ -51,7 +51,7 @@ module Axlsx # @see color def rgb=(v) Axlsx::validate_string(v) - v.upcase! + v = v.upcase v = v * 3 if v.size == 2 v = v.rjust(8, 'FF') raise ArgumentError, "Invalid color rgb value: #{v}." unless v.match(/[0-9A-F]{8}/) diff --git a/test/stylesheet/tc_color.rb b/test/stylesheet/tc_color.rb index affa2227..dd8e98d2 100644 --- a/test/stylesheet/tc_color.rb +++ b/test/stylesheet/tc_color.rb @@ -27,6 +27,12 @@ class TestColor < Test::Unit::TestCase assert_equal(@item.rgb, "FF00FF00" ) end + def test_rgb_writer_doesnt_mutate_its_argument + my_rgb = 'ff00ff00' + @item.rgb = my_rgb + assert_equal 'ff00ff00', my_rgb + end + def test_tint assert_raise(ArgumentError) { @item.tint = -1 } assert_nothing_raised { @item.tint = -1.0 } |
