Sha256: bed34c1bfe3e5a98616e335cdf1dcd08eaa2f8ee279650fec8ad6e6b294bd0c6

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

# encoding: utf-8

ActiveRecord::Migrator.migrate File.expand_path('../../../../db/migrate/', __FILE__)

def insert_user  
  User.truncate!
  password = Rails.env.production? ? Devise.friendly_token : (1..6).to_a.join
  
  admin = User.new do |u|
    u.email = 'test@test.com'
    u.password = password
    u.password_confirmation = password
    u.user_role_id = UserRoleType.admin.id
  end
    
  admin.activate!
  admin.save!

  puts "Admin: #{admin.email}, #{admin.password}"
end

def insert_structures
  Structure.truncate!
  
  main_page = Structure.create!({:title => 'Главная страница', :slug => 'main-page', :structure_type => StructureType.main, :parent => nil}, :as => :admin)
end

insert_user
insert_structures

Dir[File.join(Rails.root.join('../factories'), '*.rb')].each { |f| load f }
def test_structure
  Structure.truncate!

  main_page = Structure.create!({:title => 'Главная страница', :slug => 'main-page', :structure_type => StructureType.main, :parent => nil}, :as => :admin)
  3.times do |i|
    parent = FactoryGirl.create(:structure_page, :title => "node #{i}")
    2.times do |ii|
      child = FactoryGirl.create(:structure_page, :title => "node #{i} - #{ii}", :parent => parent)
      2.times do |iii|
        FactoryGirl.create(:structure_page, :title => "node #{i} - #{ii} - #{iii}", :parent => child)
      end
    end
  end
  Structure.rebuild!
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ab_admin-0.2.3 spec/dummy/db/seeds.rb
ab_admin-0.2.2 spec/dummy/db/seeds.rb
ab_admin-0.2.1 spec/dummy/db/seeds.rb
ab_admin-0.2.0 spec/dummy/db/seeds.rb
ab_admin-0.1.2 spec/dummy/db/seeds.rb
ab_admin-0.1.1 spec/dummy/db/seeds.rb
ab_admin-0.1.0 spec/dummy/db/seeds.rb