Sha256: a89cd248eab00714285f2dff8c0bf69f62ff8f65cfd25b1091a36da180fe6a13

Contents?: true

Size: 1.75 KB

Versions: 12

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

12 entries across 12 versions & 2 rubygems

Version Path
ecm_downloads2-1.2.2 lib/tasks/ecm_downloads_tasks.rake
ecm_downloads2-1.2.1 lib/tasks/ecm_downloads_tasks.rake
ecm_downloads2-1.2.0 lib/tasks/ecm_downloads_tasks.rake
ecm_downloads2-1.1.1 lib/tasks/ecm_downloads_tasks.rake
ecm_downloads2-1.1.0 lib/tasks/ecm_downloads_tasks.rake
ecm_downloads2-1.0.0 lib/tasks/ecm_downloads_tasks.rake
ecm_downloads-0.0.11.pre lib/tasks/ecm_downloads_tasks.rake
ecm_downloads-0.0.10.pre lib/tasks/ecm_downloads_tasks.rake
ecm_downloads-0.0.8.pre lib/tasks/ecm_downloads_tasks.rake
ecm_downloads-0.0.7.pre lib/tasks/ecm_downloads_tasks.rake
ecm_downloads-0.0.6.pre lib/tasks/ecm_downloads_tasks.rake
ecm_downloads-0.0.5.pre lib/tasks/ecm_downloads_tasks.rake