Testing Order Model Version Creation in PaperTrail
This test suite evaluates the versioning functionality of the Order model in PaperTrail, specifically focusing on association tracking during record destruction. It verifies that version records are properly created and maintained when associated records are destroyed, ensuring data history integrity.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
paper-trail-gem/paper_trail
spec/models/order_spec.rb
# frozen_string_literal: true
require "spec_helper"
RSpec.describe Order, type: :model, versioning: true do
context "when the record destroyed" do
it "creates a version record for association" do
customer = Customer.create!
described_class.create!(customer: customer)
described_class.destroy_all
expect(customer.versions.count).to(eq(3))
end
end
end