diff options
| author | Stefan Daschek <[email protected]> | 2013-07-08 14:15:32 +0200 |
|---|---|---|
| committer | Stefan Daschek <[email protected]> | 2013-07-08 14:15:32 +0200 |
| commit | b7e14c242c0d9fc3af7b7ad969ec25df21475547 (patch) | |
| tree | 6e08e812a46ebd19463db88027c77f21760d2c87 /test | |
| parent | a60d1889744205dbc86ce0e23f8ed04ba7093d23 (diff) | |
| download | caxlsx-b7e14c242c0d9fc3af7b7ad969ec25df21475547.tar.gz caxlsx-b7e14c242c0d9fc3af7b7ad969ec25df21475547.zip | |
Make sure serializing axlsx packages with identical contents always results in identical zip files.
This improves the possibilites for caching and/or consolidating the generated zip (xlsx) files.
Up to now, serializing the same package at different times resulted in different zip files because of the timestamp in the zip entry metadata.
Note: To generate identical packages (and thus identical zip files), you'll have set Core#created explicitly, eg. with `Package.new(created_at: Time.local(2013, 1, 1)`.
Diffstat (limited to 'test')
| -rw-r--r-- | test/tc_helper.rb | 1 | ||||
| -rw-r--r-- | test/tc_package.rb | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/test/tc_helper.rb b/test/tc_helper.rb index 08dec0b3..af40a1e4 100644 --- a/test/tc_helper.rb +++ b/test/tc_helper.rb @@ -6,4 +6,5 @@ SimpleCov.start do end require 'test/unit' +require "timecop" require "axlsx.rb" diff --git a/test/tc_package.rb b/test/tc_package.rb index df096a31..86f11dd4 100644 --- a/test/tc_package.rb +++ b/test/tc_package.rb @@ -123,6 +123,16 @@ class TestPackage < Test::Unit::TestCase end end end + + # See comment for Package#zip_entry_for_part + def test_serialization_creates_identical_files_at_any_time_if_created_at_is_set + @package.core.created = Time.now + zip_content_now = @package.to_stream.string + Timecop.travel(3600) do + zip_content_then = @package.to_stream.string + assert zip_content_then == zip_content_now, "zip files are not identical" + end + end def test_validation assert_equal(@package.validate.size, 0, @package.validate) |
