Sha256: 27ea5626fba05844aef7bd2ca0be63d997609f6c553d42e61957437edc590866

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 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.3.6 spec/dummy/db/seeds.rb
ab_admin-0.3.5 spec/dummy/db/seeds.rb
ab_admin-0.3.4 spec/dummy/db/seeds.rb
ab_admin-0.3.3 spec/dummy/db/seeds.rb
ab_admin-0.3.2 spec/dummy/db/seeds.rb
ab_admin-0.3.1 spec/dummy/db/seeds.rb
ab_admin-0.3.0 spec/dummy/db/seeds.rb