Sha256: 866002161205684b441479ac084406a706955cc15130679704df918c23ee43f0

Contents?: true

Size: 703 Bytes

Versions: 3

Compression:

Stored size: 703 Bytes

Contents

require_relative "test_helper"

class ReadonlyWhenArchivedTest < ActiveSupport::TestCase
  test "acts_as_archival objects can normally be altered after archive" do
    archival = Archival.create!(:name => "original")
    archival.archive
    archival.name = "updated"
    archival.save!

    assert_equal "updated", archival.reload.name
  end

  test "acts_as_archival marked as readonly_when_archived cannot be updated after archive" do
    archival = ReadonlyWhenArchived.create!(:name => "original")
    archival.archive
    archival.name = "updated"

    assert_not archival.save
    assert_equal "Cannot modifify an archived record.",
                 archival.errors.full_messages.first
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
acts_as_archival-0.4.2 test/readonly_when_archived_test.rb
acts_as_archival-0.4.1 test/readonly_when_archived_test.rb
acts_as_archival-0.4.0 test/readonly_when_archived_test.rb