Sha256: 8d172816190f8827f0f6837b7464a5b3f725cbbf6b959a41ecb7b689f9776497
Contents?: true
Size: 1.75 KB
Versions: 9
Compression:
Stored size: 1.75 KB
Contents
namespace :ecm_downloads do namespace :db do desc 'Purges and creates example data' task :populate!, [] => [:environment] do |_t, _args| Rake::Task['ecm_downloads:db:clear!'].execute Rake::Task['ecm_downloads:db:populate'].execute end desc 'Clears all data!' task :clear!, [] => [:environment] do |_t, _args| Ecm::Downloads::DownloadCategory.delete_all Ecm::Downloads::Download.delete_all end desc 'Creates example_data' task :populate, [] => [:environment] do |_t, _args| require 'ffaker' require 'forgery' # Create example download category roots 10.times do Ecm::Downloads::DownloadCategory.create! do |dc| dc.locale = I18n.available_locales.choice.to_s dc.name = Faker::Product.brand dc.description = Faker::Lorem.paragraph(rand(10)) end end # Create example download sub-categories 10.times do Ecm::Downloads::DownloadCategory.create! do |dc| dc.parent = Ecm::Downloads::DownloadCategory.all.choice dc.name = Faker::Product.brand dc.description = Faker::Lorem.paragraph(rand(10)) end end # Create example downloads download_categories = Ecm::Downloads::DownloadCategory.all 100.times do Ecm::Downloads::Download.create! do |d| d.ecm_downloads_download_category = download_categories.choice d.name = Faker::Product.product_name d.asset = File.open(Ecm::Downloads::Engine.root + 'spec/fixtures/download/example.txt') d.published = [true, false].choice d.description = Faker::Lorem.paragraph(rand(10)) end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems