Sha256: 50ada54dad0dad42da73c42e097e8771cbc175f2f0efb4d0384659c68ce386c1

Contents?: true

Size: 993 Bytes

Versions: 3

Compression:

Stored size: 993 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,
      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

3 entries across 3 versions & 1 rubygems

Version Path
archival_record-2.0.2 test/deep_nesting_test.rb
archival_record-2.0.1 test/deep_nesting_test.rb
archival_record-2.0.0 test/deep_nesting_test.rb