Sha256: 1e20556269626f90f973af6d1b7bcdc42cd31b161387ed778f98ad478aad8287

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 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
      result = subject.assets_under_embargo
      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

4 entries across 4 versions & 1 rubygems

Version Path
hydra-access-controls-10.6.1 spec/services/embargo_service_spec.rb
hydra-access-controls-10.6.0 spec/services/embargo_service_spec.rb
hydra-access-controls-10.5.1 spec/services/embargo_service_spec.rb
hydra-access-controls-11.0.0.rc1 spec/services/embargo_service_spec.rb