Sha256: babc9f5b0b494c0b54867656ac236a11f36fbe67282ee0bf34147c452c4f2255

Contents?: true

Size: 1.46 KB

Versions: 6

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

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

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

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

  let!(:work_with_embargo_in_effect) { FactoryGirl.create(:generic_work, embargo_release_date: future_date.to_s)}
  let!(:work_without_embargo) { FactoryGirl.create(:generic_work)}

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
worthwhile-0.1.2 spec/services/embargo_service_spec.rb
worthwhile-0.1.1 spec/services/embargo_service_spec.rb
worthwhile-0.1.0 spec/services/embargo_service_spec.rb
worthwhile-0.0.3 spec/services/embargo_service_spec.rb
worthwhile-0.0.2 spec/services/embargo_service_spec.rb
worthwhile-0.0.1 spec/services/embargo_service_spec.rb