Sha256: 60ab1b66e131d4af615f2c5cab5aa1ab4b802c0c61da32743b0f042292a55aa1
Contents?: true
Size: 980 Bytes
Versions: 2
Compression:
Stored size: 980 Bytes
Contents
FactoryGirl.define do factory :asset, class: 'Landable::Asset' do ignore do asset_dir { Landable::Engine.root.join('spec', 'fixtures', 'assets') } all_fixtures { ['panda.png', 'cthulhu.jpg', 'small.pdf', 'sloth.png'] } sequence(:fixture) do taken = Landable::Asset.pluck(:data) all_fixtures.find { |name| !taken.include?(name) }.tap do |available| fail "Add more files to spec/fixtures/assets; we've only got #{all_fixtures.length} available." if available.nil? end end end sequence(:name) { |n| "asset_upload_#{n}" } sequence(:description) { |n| "what a useful asset #{n}" } author data do path = File.join asset_dir, fixture mime = case path when /\.png$/ then 'image/png' when /\.jpe?g$/ then 'image/jpeg' when /\.pdf$/ then 'application/pdf' end Rack::Test::UploadedFile.new(path, mime) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
landable-1.14.0 | spec/factories/asset.rb |
landable-1.13.2 | spec/factories/asset.rb |