Sha256: eeac595391f45b1a5cb4d547ab7b1745791fb0096526175874180f435143c56f

Contents?: true

Size: 1.43 KB

Versions: 7

Compression:

Stored size: 1.43 KB

Contents

require 'jdbc/sqlite3' if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
require 'digest/sha1'

DataMapper.setup(:default, 'sqlite3::memory:')

# Fake Category Model
class Category
  include DataMapper::Resource
  property :id,   Serial
  property :name, String
  belongs_to :account
end

# Fake Account Model
class Account
  include DataMapper::Resource
  include DataMapper::Validate
  attr_accessor :password, :password_confirmation

  # Properties
  property :id,               Serial
  property :name,             String
  property :surname,          String
  property :email,            String
  property :crypted_password, String
  property :salt,             String
  property :role,             String

  has n, :categories
  def self.admin;  first(:role => "admin");  end
  def self.editor; first(:role => "editor"); end

  ##
  # This method is used from AuthenticationHelper
  #
  def self.find_by_id(id)
    get(id)
  end
end

DataMapper.auto_migrate!

# We build some fake accounts
admin  = Account.create(:name => "DAddYE", :role => "admin",  :email => "d.dagostino@lipsiasoft.com",
                        :password => "some", :password_confirmation => "some")
editor = Account.create(:name => "Dexter", :role => "editor", :email => "editor@lipsiasoft.com",
                        :password => "some", :password_confirmation => "some")

%w(News Press HowTo).each do |c|
  admin.categories.create(:name => c)
  editor.categories.create(:name => c)
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
padrino-admin-0.12.8.1 test/fixtures/data_mapper.rb
padrino-admin-0.12.8 test/fixtures/data_mapper.rb
padrino-admin-0.12.7 test/fixtures/data_mapper.rb
padrino-admin-0.12.6 test/fixtures/data_mapper.rb
padrino-admin-0.12.5 test/fixtures/data_mapper.rb
padrino-admin-0.12.4 test/fixtures/data_mapper.rb
padrino-admin-0.12.3 test/fixtures/data_mapper.rb