Sha256: 724b0c2b831ab641a642e625ffe47d4cb8362b8648d9077c0dde87906458dc11

Contents?: true

Size: 1.37 KB

Versions: 12

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'

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

  let!(:work_with_expired_embargo1) do
    FactoryBot.build(:asset, embargo_release_date: past_date.to_s).tap do |work|
      work.save(validate:false)
    end
  end

  let!(:work_with_expired_embargo2) do
    FactoryBot.build(:asset, embargo_release_date: past_date.to_s).tap do |work|
      work.save(validate:false)
    end
  end

  let!(:work_with_embargo_in_effect) { FactoryBot.create(:asset, embargo_release_date: future_date.to_s)}
  let!(:work_without_embargo) { FactoryBot.create(:asset)}

  describe "#assets_with_expired_embargoes" do
    it "returns an array of assets with expired embargoes" do
      returned_ids = subject.assets_with_expired_embargoes.map {|a| a.id}
      expect(returned_ids).to include work_with_expired_embargo1.id, work_with_expired_embargo2.id
      expect(returned_ids).to_not include work_with_embargo_in_effect.id, work_without_embargo.id
    end
  end

  describe "#assets_under_embargo" do
    it "returns all assets with embargo release date set" do
      returned_ids = subject.assets_under_embargo.map {|a| a.id}
      expect(returned_ids).to include work_with_expired_embargo1.id, work_with_expired_embargo2.id, work_with_embargo_in_effect.id
      expect(returned_ids).to_not include work_without_embargo.id
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hydra-access-controls-13.0.0 spec/services/embargo_service_spec.rb
hydra-access-controls-12.1.0 spec/services/embargo_service_spec.rb
hydra-access-controls-12.0.2 spec/services/embargo_service_spec.rb
hydra-access-controls-11.0.7 spec/services/embargo_service_spec.rb
hydra-access-controls-12.0.1 spec/services/embargo_service_spec.rb
hydra-access-controls-11.0.6 spec/services/embargo_service_spec.rb
hydra-access-controls-12.0.0 spec/services/embargo_service_spec.rb
hydra-access-controls-11.0.1 spec/services/embargo_service_spec.rb
hydra-access-controls-11.0.0 spec/services/embargo_service_spec.rb
hydra-access-controls-11.0.0.rc2 spec/services/embargo_service_spec.rb
hydra-access-controls-10.7.0 spec/services/embargo_service_spec.rb
hydra-access-controls-10.6.2 spec/services/embargo_service_spec.rb