Skip to content

Instantly share code, notes, and snippets.

@mhfs
Created October 30, 2009 16:54
Show Gist options
  • Save mhfs/222522 to your computer and use it in GitHub Desktop.
Save mhfs/222522 to your computer and use it in GitHub Desktop.
Factory.define :account do |ac|
ac.sequence(:name) { |n| "Account#{n}" }
ac.sequence(:subdomain) { |n| "subdomain#{n}" }
ac.users { |a| [a.association(:user, :account_id => ac.object_id), a.association(:user, :account_id => ac.object_id)] }
end
Factory.define :user do |u|
u.sequence(:name) { |n| "John Doe #{n}" }
u.sequence(:username) { |n| "user#{n}" }
u.sequence(:email) { |n| "email#{n}@example.com" }
u.password "123mudar"
u.password_confirmation { |u| u.password }
u.association :account
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment