summaryrefslogtreecommitdiffhomepage
path: root/test/tc_package.rb
diff options
context:
space:
mode:
authorStefan Daschek <[email protected]>2013-07-08 14:15:32 +0200
committerStefan Daschek <[email protected]>2013-07-08 14:15:32 +0200
commitb7e14c242c0d9fc3af7b7ad969ec25df21475547 (patch)
tree6e08e812a46ebd19463db88027c77f21760d2c87 /test/tc_package.rb
parenta60d1889744205dbc86ce0e23f8ed04ba7093d23 (diff)
downloadcaxlsx-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/tc_package.rb')
-rw-r--r--test/tc_package.rb10
1 files changed, 10 insertions, 0 deletions
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)