Sha256: 62e9f149684c572610a0f45c204add6ba9ba67ec6b575f285c0272b86d038e9c

Contents?: true

Size: 997 Bytes

Versions: 2

Compression:

Stored size: 997 Bytes

Contents

require_relative "test_helper"

class DeepNestingTest < ActiveSupport::TestCase

  test "archiving deeply nested items" do
    archival = Archival.create!
    child = archival.archivals.create!
    grandchild = child.archivals.create!

    archival.archive!

    assert archival.reload.archived?
    assert child.reload.archived?
    assert grandchild.reload.archived?
    assert_equal archival.archive_number, child.archive_number
    assert_equal archival.archive_number, grandchild.archive_number
  end

  test "unarchiving deeply nested items doesn't blow up" do
    archival_attributes = {
      archived_at: Time.now.utc,
      archive_number: "test"
    }
    archival = Archival.create!(archival_attributes)
    child = archival.archivals.create!(archival_attributes)
    grandchild = child.archivals.create!(archival_attributes)

    archival.unarchive!

    assert_not archival.reload.archived?
    assert_not child.reload.archived?
    assert_not grandchild.reload.archived?
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
archival_record-3.0.1 test/deep_nesting_test.rb
archival_record-3.0.0 test/deep_nesting_test.rb