Commit b29719e00d212cb90be368ef6ba92231d1f45983

Authored by AntonioTerceiro
1 parent 0e3803b1

ActionItem65: populating anhetegua sample data



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@554 3f533792-8f58-4932-b0fe-aaf55b0a4547
script/anhetegua 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +#!/usr/bin/env ruby
  2 +require File.dirname(__FILE__) + '/../config/environment'
  3 +
  4 +Environment.default.categories.destroy_all
  5 +
  6 +def new_category(parent, name, color = nil)
  7 + category = Environment.default.categories.build(:name => name, :display_color => color, :parent_id => (parent ? parent.id: nil))
  8 + category.save!
  9 + category
  10 +end
  11 +
  12 +tematicas = new_category(nil, 'Temáticas', 1)
  13 +new_category(tematicas, 'Finanças Solidárias')
  14 +new_category(tematicas, 'Marco Legal')
  15 +new_category(tematicas, 'Software Livre')
  16 +
  17 +territorios = new_category(nil, 'Territórios', 2)
  18 +new_category(territorios, 'Bahia')
  19 +new_category(territorios, 'Distrito Federal')
  20 +new_category(territorios, 'Rio Grande do Sul')
  21 +
  22 +cadeias = new_category(nil, 'Cadeias', 3)
  23 +new_category(cadeias, 'Algodão')
  24 +new_category(cadeias, 'Tecnologia de Informação')
... ...
script/populate
... ... @@ -5,3 +5,5 @@ User.create!(:login => 'testprofile', :email => 'admin@example.com', :password =
5 5 User.create!(:login => 'user', :email => 'user@example.com', :password => 'user', :password_confirmation => 'user')
6 6 User.create!(:login => 'usuario', :email => 'usuario@example.com', :password => 'usuario', :password_confirmation => 'usuario')
7 7 User.create!(:login => 'ze', :email => 'ze@example.com', :password => 'test', :password_confirmation => 'test')
  8 +
  9 +
... ...
script/reset_db
... ... @@ -5,3 +5,4 @@ system "rm #{RAILS_ROOT}/tmp/*.db"
5 5 system "rake db:migrate VERSION=0"
6 6 system "rake db:migrate"
7 7 system "ruby #{RAILS_ROOT}/script/populate"
  8 +system "rake db:test:prepare"
... ...