Sha256: 60fb73a0e40b899115f455f89e5f8fbb94e89e73393ae760a8de15f9fa8ff9fb

Contents?: true

Size: 1.42 KB

Versions: 44

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
    FactoryGirl.build(:asset, embargo_release_date: past_date.to_s).tap do |work|
      work.save(validate:false)
    end
  end

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

  let!(:work_with_embargo_in_effect) { FactoryGirl.create(:asset, embargo_release_date: future_date.to_s)}
  let!(:work_without_embargo) { FactoryGirl.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

44 entries across 44 versions & 1 rubygems

Version Path
hydra-access-controls-10.5.0 spec/services/embargo_service_spec.rb
hydra-access-controls-10.4.0 spec/services/embargo_service_spec.rb
hydra-access-controls-10.4.0.rc2 spec/services/embargo_service_spec.rb
hydra-access-controls-10.4.0.rc1 spec/services/embargo_service_spec.rb
hydra-access-controls-10.3.4 spec/services/embargo_service_spec.rb
hydra-access-controls-10.3.3 spec/services/embargo_service_spec.rb
hydra-access-controls-10.3.2 spec/services/embargo_service_spec.rb
hydra-access-controls-10.3.0 spec/services/embargo_service_spec.rb
hydra-access-controls-10.2.0 spec/services/embargo_service_spec.rb
hydra-access-controls-10.1.0 spec/services/embargo_service_spec.rb
hydra-access-controls-10.0.2 spec/services/embargo_service_spec.rb
hydra-access-controls-10.0.1 spec/services/embargo_service_spec.rb
hydra-access-controls-10.0.0 spec/services/embargo_service_spec.rb
hydra-access-controls-10.0.0.beta4 spec/services/embargo_service_spec.rb
hydra-access-controls-10.0.0.beta3 spec/services/embargo_service_spec.rb
hydra-access-controls-10.0.0.beta2 spec/services/embargo_service_spec.rb
hydra-access-controls-10.0.0.beta1 spec/services/embargo_service_spec.rb
hydra-access-controls-9.10.0 spec/services/embargo_service_spec.rb
hydra-access-controls-9.9.0 spec/services/embargo_service_spec.rb
hydra-access-controls-9.8.1 spec/services/embargo_service_spec.rb