Sha256: 2c0ccddeb765385b4596cdb10348e046db5c55c01e62d1aba0920362afd82b28

Contents?: true

Size: 1.91 KB

Versions: 4

Compression:

Stored size: 1.91 KB

Contents

FactoryGirl.define do
  factory :work, aliases: [:generic_work, :private_generic_work], class: GenericWork do
    ignore do
      user { FactoryGirl.create(:user) }
      embargo_date { Date.tomorrow.to_s }
    end

    title ["Test title"]
    visibility Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE

    before(:create) do |work, evaluator|
      work.apply_depositor_metadata(evaluator.user.user_key)
    end


    factory :public_generic_work do
      visibility Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
    end

    factory :work_with_files do
      after(:build) { |work, _| 2.times { work.generic_files << FactoryGirl.build(:generic_file) }}
    end

    factory :embargoed_work do
      after(:build) { |work, evaluator| work.apply_embargo(evaluator.embargo_date, Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE, Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC) }
    end

    factory :embargoed_work_with_files do
      after(:build) { |work, _| 2.times { work.generic_files << FactoryGirl.build(:generic_file) }}
      after(:build) { |work, evaluator| work.apply_embargo(evaluator.embargo_date, Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE, Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC) }
    end

    factory :leased_work do
      after(:build) { |work, evaluator| work.apply_lease(evaluator.embargo_date, Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC, Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE) }
    end

    factory :leased_work_with_files do
      after(:build) { |work, _| 2.times { work.generic_files << FactoryGirl.build(:generic_file) }}
      after(:build) { |work, evaluator| work.apply_lease(evaluator.embargo_date, Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC, Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE) }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
worthwhile-0.1.2 spec/factories/generic_works.rb
worthwhile-0.1.1 spec/factories/generic_works.rb
worthwhile-0.1.0 spec/factories/generic_works.rb
worthwhile-0.0.3 spec/factories/generic_works.rb