Sha256: 1802ba800cd14ca7b4273508a3401bcc7af4d7788114d1ab15ea6efec448aaac

Contents?: true

Size: 699 Bytes

Versions: 4

Compression:

Stored size: 699 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 modify an archived record.",
                 archival.errors.full_messages.first
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
acts_as_archival-2.1.0 test/readonly_when_archived_test.rb
acts_as_archival-2.0.0 test/readonly_when_archived_test.rb
acts_as_archival-1.4.0 test/readonly_when_archived_test.rb
acts_as_archival-1.3.0 test/readonly_when_archived_test.rb