Sha256: 67617349c8e52f0104b399719901e4ab8f29d60a795539569930fffcc13cb715

Contents?: true

Size: 1.79 KB

Versions: 20

Compression:

Stored size: 1.79 KB

Contents

require 'spec_helper'

describe ChecksumAuditLog do
  before(:all) do
    @f = GenericFile.new
    @f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
    @f.apply_depositor_metadata('mjg36')
    @f.stub(:characterize_if_changed).and_yield #don't run characterization
    @f.save!
    @version = @f.datastreams['content'].versions.first
    @old = ChecksumAuditLog.create(:pid=>@f.pid, :dsid=>@version.dsid, :version=>@version.versionID, :pass=>1, :created_at=>2.minutes.ago)
    @new = ChecksumAuditLog.create(:pid=>@f.pid, :dsid=>@version.dsid, :version=>@version.versionID, :pass=>0)
  end
  after(:all) do
    @f.delete
    ChecksumAuditLog.all.each(&:delete)
  end
  before(:each) do
    GenericFile.any_instance.stub(:characterize).and_return(true) # stub out characterization so it does not get audited
  end
  it "should return a list of logs for this datastream sorted by date descending" do
    @f.logs(@version.dsid).should == [@new, @old]
  end
  it "should prune history for a datastream" do
    success1 = ChecksumAuditLog.create(:pid=>@f.pid, :dsid=>@version.dsid, :version=>@version.versionID, :pass=>1)
    ChecksumAuditLog.prune_history(@version)
    success2 = ChecksumAuditLog.create(:pid=>@f.pid, :dsid=>@version.dsid, :version=>@version.versionID, :pass=>1)
    ChecksumAuditLog.prune_history(@version)
    success3 = ChecksumAuditLog.create(:pid=>@f.pid, :dsid=>@version.dsid, :version=>@version.versionID, :pass=>1)
    ChecksumAuditLog.prune_history(@version)
    lambda { ChecksumAuditLog.find(success2.id)}.should raise_exception ActiveRecord::RecordNotFound
    lambda { ChecksumAuditLog.find(success3.id)}.should raise_exception ActiveRecord::RecordNotFound
    ChecksumAuditLog.find(success1.id).should_not be_nil
    @f.logs(@version.dsid).should == [success1, @new, @old]
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
sufia-4.0.0.beta2 spec/models/checksum_audit_log_spec.rb
sufia-4.0.0.beta1 spec/models/checksum_audit_log_spec.rb
sufia-3.7.2 spec/models/checksum_audit_log_spec.rb
sufia-3.7.1 spec/models/checksum_audit_log_spec.rb
sufia-3.7.0 spec/models/checksum_audit_log_spec.rb
sufia-3.6.1 spec/models/checksum_audit_log_spec.rb
sufia-3.6.0 spec/models/checksum_audit_log_spec.rb
sufia-3.5.0 spec/models/checksum_audit_log_spec.rb
sufia-3.4.0 spec/models/checksum_audit_log_spec.rb
sufia-3.4.0.rc4 spec/models/checksum_audit_log_spec.rb
sufia-3.4.0.rc3 spec/models/checksum_audit_log_spec.rb
sufia-3.3.1 spec/models/checksum_audit_log_spec.rb
sufia-3.4.0.rc2 spec/models/checksum_audit_log_spec.rb
sufia-3.4.0.rc1 spec/models/checksum_audit_log_spec.rb
sufia-3.3.0 spec/models/checksum_audit_log_spec.rb
sufia-3.2.1 spec/models/checksum_audit_log_spec.rb
sufia-3.1.3 spec/models/checksum_audit_log_spec.rb
sufia-3.1.2 spec/models/checksum_audit_log_spec.rb
sufia-3.1.1 spec/models/checksum_audit_log_spec.rb
sufia-3.1.0 spec/models/checksum_audit_log_spec.rb