Sha256: 407387973e4fe146f48eebca5233df8286d6588542ad721bbb080e9f0c0d1b00
Contents?: true
Size: 1.92 KB
Versions: 2
Compression:
Stored size: 1.92 KB
Contents
require_relative "test_helper" class BasicTest < ActiveSupport::TestCase test "archive archives the record" do archival = Archival.create! archival.archive assert archival.reload.archived? end test "unarchive unarchives archival records" do archival = Archival.create!(:archived_at => Time.now, :archive_number => 1) archival.unarchive assert_not archival.reload.archived? end test "archive returns true on success" do normal = Archival.create! assert_equal true, normal.archive end test "archive returns false on failure" do readonly = Archival.create! readonly.readonly! assert_equal false, readonly.archive end test "unarchive returns true on success" do normal = Archival.create!(:archived_at => Time.now, :archive_number => "1") assert_equal true, normal.unarchive end test "unarchive returns false on failure" do readonly = Archival.create!(:archived_at => Time.now, :archive_number => "1") readonly.readonly! assert_equal false, readonly.unarchive end test "archive sets archived_at to the time of archiving" do archival = Archival.create! before = DateTime.now sleep(0.001) archival.archive sleep(0.001) after = DateTime.now assert before < archival.archived_at.to_datetime assert after > archival.archived_at.to_datetime end test "archive sets the archive number to the md5 hexdigest for the model and id that is archived" do archival = Archival.create! archival.archive expected_digest = Digest::MD5.hexdigest("#{archival.class.name}#{archival.id}") assert_equal expected_digest, archival.archive_number end test "archive on archived object doesn't alter the archive_number" do archived = Archival.create archived.archive initial_number = archived.archive_number archived.reload.archive second_number = archived.archive_number assert_equal initial_number, second_number end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
acts_as_archival-0.6.1 | test/basic_test.rb |
acts_as_archival-0.6.0 | test/basic_test.rb |