Sha256: 29f60d9827142fc8a8af6b2ca289583c6536b123fc6cdd156c03c74b17632370

Contents?: true

Size: 913 Bytes

Versions: 2

Compression:

Stored size: 913 Bytes

Contents

require_relative "test_helper"
require "rr"

class TransactionTest < ActiveSupport::TestCase

  test "archiving is transactional" do
    archival = Archival.create!
    exploder = archival.exploders.create!
    any_instance_of(Exploder) do |canary|
      stub(canary).archive! { raise "Rollback Imminent" }
    end
    archival.archive!

    failure_reason = "If this failed, you might be trying to test on a system that doesn't support nested transactions"
    assert_not archival.archived?, failure_reason
    assert_not exploder.reload.archived?
  end

  test "unarchiving is transactional" do
    archival = Archival.create!
    exploder = archival.exploders.create!
    any_instance_of(Exploder) do |canary|
      stub(canary).unarchive! { raise "Rollback Imminent" }
    end
    archival.archive!
    archival.unarchive!

    assert archival.reload.archived?
    assert exploder.reload.archived?
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

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