Sha256: 681f93998b86718904054b45af8f19c9eba8186a7e446f609b44ac3ccad3a335

Contents?: true

Size: 1.36 KB

Versions: 10

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'

describe Hydra::LeaseService do
  let(:future_date) { 2.days.from_now }
  let(:past_date) { 2.days.ago }

  let!(:work_with_expired_lease1) do
    FactoryGirl.build(:asset, lease_expiration_date: past_date.to_s).tap do |work|
      work.save(validate: false)
    end
  end

  let!(:work_with_expired_lease2) do
    FactoryGirl.build(:asset, lease_expiration_date: past_date.to_s).tap do |work|
      work.save(validate: false)
    end
  end

  let!(:work_with_lease_in_effect) { FactoryGirl.create(:asset, lease_expiration_date: future_date.to_s)}
  let!(:work_without_lease) { FactoryGirl.create(:asset)}

  describe "#assets_with_expired_leases" do
    it "returns an array of assets with expired embargoes" do
      returned_pids = subject.assets_with_expired_leases.map {|a| a.pid}
      expect(returned_pids).to include work_with_expired_lease1.pid,work_with_expired_lease2.pid
      expect(returned_pids).to_not include work_with_lease_in_effect.pid,work_without_lease.pid
    end
  end

  describe "#assets_under_lease" do
    it "returns an array of assets with expired embargoes" do
      returned_pids = subject.assets_under_lease.map {|a| a.pid}
      expect(returned_pids).to include work_with_expired_lease1.pid,work_with_expired_lease2.pid,work_with_lease_in_effect.pid
      expect(returned_pids).to_not include work_without_lease.pid
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hydra-access-controls-8.2.0 spec/services/lease_service_spec.rb
hydra-access-controls-8.1.0 spec/services/lease_service_spec.rb
hydra-access-controls-8.0.0 spec/services/lease_service_spec.rb
hydra-access-controls-8.0.0.beta1 spec/services/lease_service_spec.rb
hydra-access-controls-7.2.2 spec/services/lease_service_spec.rb
hydra-access-controls-7.2.1 spec/services/lease_service_spec.rb
hydra-access-controls-7.2.0 spec/services/lease_service_spec.rb
hydra-access-controls-7.1.0 spec/services/lease_service_spec.rb
hydra-access-controls-7.1.0.rc2 spec/services/lease_service_spec.rb
hydra-access-controls-7.1.0.rc1 spec/services/lease_service_spec.rb