69 lines
1.7 KiB
Ruby
69 lines
1.7 KiB
Ruby
FactoryBot.define do
|
|
factory :image do
|
|
attachment { Rack::Test::UploadedFile.new("spec/fixtures/files/clippy.jpg") }
|
|
title { "Lorem ipsum dolor sit amet" }
|
|
association :user, factory: :user
|
|
|
|
trait :proposal_image do
|
|
association :imageable, factory: :proposal
|
|
end
|
|
|
|
trait :budget_image do
|
|
association :imageable, factory: :budget
|
|
end
|
|
|
|
trait :budget_investment_image do
|
|
association :imageable, factory: :budget_investment
|
|
end
|
|
end
|
|
|
|
factory :document do
|
|
sequence(:title) { |n| "Document title #{n}" }
|
|
association :user, factory: :user
|
|
attachment { Rack::Test::UploadedFile.new("spec/fixtures/files/empty.pdf") }
|
|
|
|
trait :proposal_document do
|
|
association :documentable, factory: :proposal
|
|
end
|
|
|
|
trait :budget_investment_document do
|
|
association :documentable, factory: :budget_investment
|
|
end
|
|
|
|
trait :poll_question_document do
|
|
association :documentable, factory: :poll_question
|
|
end
|
|
|
|
trait :admin do
|
|
admin { true }
|
|
end
|
|
end
|
|
|
|
factory :direct_upload do
|
|
user
|
|
|
|
trait :proposal do
|
|
resource_type { "Proposal" }
|
|
end
|
|
trait :budget_investment do
|
|
resource_type { "Budget::Investment" }
|
|
end
|
|
|
|
trait :documents do
|
|
resource_relation { "documents" }
|
|
attachment { Rack::Test::UploadedFile.new("spec/fixtures/files/empty.pdf") }
|
|
end
|
|
trait :image do
|
|
resource_relation { "image" }
|
|
attachment { Rack::Test::UploadedFile.new("spec/fixtures/files/clippy.jpg") }
|
|
end
|
|
initialize_with { new(attributes) }
|
|
end
|
|
|
|
factory :active_storage_blob, class: "ActiveStorage::Blob" do
|
|
filename { "sample.pdf" }
|
|
byte_size { 3000 }
|
|
checksum { SecureRandom.hex(32) }
|
|
end
|
|
end
|