Testing Gizmo Model Version Timestamp Handling in PaperTrail
This test suite examines the versioning behavior of the Gizmo model within the PaperTrail gem. It specifically focuses on timestamp handling and version creation, ensuring proper separation between model and version timestamps. The tests validate core versioning functionality while maintaining data integrity.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
paper-trail-gem/paper_trail
spec/models/gizmo_spec.rb
# frozen_string_literal: true
require "spec_helper"
require "support/performance_helpers"
RSpec.describe Gizmo, type: :model, versioning: true do
context "with a persisted record" do
it "does not use the gizmo `updated_at` as the version's `created_at`" do
gizmo = described_class.create(name: "Fred", created_at: Time.current - 1.day)
gizmo.name = "Allen"
gizmo.save(touch: false)
expect(gizmo.versions.last.created_at).not_to(eq(gizmo.updated_at))
end
end
end