test/hexapdf/test_revision.rb in hexapdf-0.27.0 vs test/hexapdf/test_revision.rb in hexapdf-0.28.0
- old
+ new
@@ -197,18 +197,33 @@
obj.value = :Other
@rev.add(@obj)
deleted = @rev.object(6)
@rev.delete(6)
assert_equal([obj, @obj, deleted], @rev.each_modified_object.to_a)
+ assert_same(obj, @rev.object(3))
end
+ it "optionally deletes the modified objects from the revision" do
+ obj = @rev.object(3)
+ obj.value = :other
+ assert_equal([obj], @rev.each_modified_object(delete: true).to_a)
+ refute_same(obj, @rev.object(3))
+ end
+
it "ignores object and xref streams that were deleted" do
@rev.delete(4)
@rev.delete(5)
assert_equal([], @rev.each_modified_object.to_a)
end
+ it "handles object and xref streams that were added appropriately depending on the 'all' arg" do
+ xref = @rev.add(HexaPDF::Dictionary.new({Type: :XRef}, oid: 8))
+ objstm = @rev.add(HexaPDF::Dictionary.new({Type: :ObjStm}, oid: 9))
+ assert_equal([], @rev.each_modified_object.to_a)
+ assert_equal([xref, objstm], @rev.each_modified_object(all: true).to_a)
+ end
+
it "doesn't return non-modified objects" do
@rev.object(2)
assert_equal([], @rev.each_modified_object.to_a)
end
@@ -226,22 +241,8 @@
it "doesn't return signature objects" do
obj = @rev.object(2)
obj[:x] = :y
assert_equal([], @rev.each_modified_object.to_a)
- end
- end
-
- describe "reset_objects" do
- it "deletes loaded objects" do
- @rev.object(2)
- @rev.reset_objects
- assert(@rev.instance_variable_get(:@objects).oids.empty?)
- end
-
- it "deletes added objects" do
- @rev.add(@obj)
- @rev.reset_objects
- assert(@rev.instance_variable_get(:@objects).oids.empty?)
end
end
end