Sha256: 15293db25c50b8aa89363f96f72138a7fec98047de369a5c826a2cc5ae269cc7

Contents?: true

Size: 920 Bytes

Versions: 2

Compression:

Stored size: 920 Bytes

Contents

# frozen_string_literal: true
FactoryBot.define do
  factory :file_set do
    transient do
      user { build(:user) }
      title { nil }
      content { nil }
    end
    after(:build) do |fs, evaluator|
      fs.apply_depositor_metadata evaluator.user.user_key
      fs.title = evaluator.title
    end

    after(:create) do |file, evaluator|
      Hydra::Works::UploadFileToFileSet.call(file, evaluator.content) if evaluator.content
    end

    trait :public do
      read_groups { ["public"] }
    end

    trait :registered do
      read_groups { ["registered"] }
    end

    factory :file_with_work do
      after(:build) do |file, _evaluator|
        file.title = ['testfile']
      end
      after(:create) do |file, evaluator|
        Hydra::Works::UploadFileToFileSet.call(file, evaluator.content) if evaluator.content
        create(:work, user: evaluator.user).members << file
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zizia-5.5.0 spec/factories/file_sets.rb
zizia-5.4.0 spec/factories/file_sets.rb