Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Fabricator(:asset) do
- end
- Fabricator(:photo, :from => :asset, :class_name => :photo) do
- user!
- category!
- title { Faker::Lorem.words }
- description { Faker::Lorem.paragraphs }
- after_build do |asset|
- asset.previews << Fabricate(:preview, :asset => asset)
- asset.products << Fabricate(:product, :asset => asset)
- end
- end
- Fabricator(:preview) do
- # asset_id { Fabricate([:brush, :pattern, :photo, :texture].sample) }
- upload { File.open("#{Rails.root}/spec/media/factory.png") }
- end
- # Test error:
- # Failure/Error: get :new, :asset_id => Fabricate(:photo).permalink
- # SQLite3::ConstraintException: previews.asset_id may not be NULL: INSERT INTO "previews" ("asset_id", "created_at", "updated_at", "upload") VALUES (NULL, '2011-03-28 18:46:12.517251', '2011-03-28 18:46:12.517251', 'factory.
- # Also tried, but got same error:
- asset.previews << Fabricate(:preview, :asset_id => asset.id)
- asset.products << Fabricate(:product, :asset_id => asset.id)
Add Comment
Please, Sign In to add comment