Files
grecia/spec/factories/files.rb
Javi Martín b88a01f641 Add and apply FactoryBot/RedundantFactoryOption rule
This rule was added in rubocop-factory_bot 2.23.0.
2023-09-08 13:39:26 +02:00

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
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
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