Created
July 24, 2009 19:57
-
-
Save gumayunov/154510 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Factory.sequence :login do |n| | |
Rufus::Mnemo::from_integer 20000+n*10000+rand(10000) | |
end | |
Factory.define :user do |u| | |
u.login {Factory.next :login} | |
u.email {|n| [n.login, "@hypermail.com"].join} | |
u.nick { Faker::Internet.user_name } | |
u.homepage { Faker::Internet::url} | |
u.password "111111" | |
u.password_confirmation {|n| n.password} | |
u.password_salt do | |
Authlogic::CryptoProviders::Sha512.encrypt(Time.now.to_s + (1..10).collect{ rand.to_s }.join) | |
end | |
u.crypted_password do |n| | |
salted = [n.password,n.password_salt].join | |
User.acts_as_authentic_config[:crypto_provider].encrypt salted | |
end | |
end | |
Factory.define :book do |b| | |
b.title { Faker::Lorem.sentence } | |
b.author { Faker::Internet.user_name } | |
end | |
Factory.define :review do |r| | |
r.title { Faker::Lorem.sentence } | |
r.author { Faker::Internet.user_name } | |
r.association :creator, :factory => :user | |
r.comment { Faker::Lorem.sentences(rand(6)).join(' ') } | |
r.opinion { %w{like dislike wanted}.rand } | |
end | |
Factory.define :review_with_book, :parent => :review do |r| | |
r.association :book, :factory => :book | |
end | |
Factory.define :old_review, :parent => :review do |r| | |
r.created_at { Populator.value_in_range( Time.now.month.ago..Time.now) } | |
r.updated_at { Time.now } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment