Skip to content

Instantly share code, notes, and snippets.

@daviddavis
Created October 11, 2012 20:56
Show Gist options
  • Select an option

  • Save daviddavis/3875430 to your computer and use it in GitHub Desktop.

Select an option

Save daviddavis/3875430 to your computer and use it in GitHub Desktop.
User factory
factory :user do
username "ehelms"
email "ehelms@redhat.com"
password "Secret1234"
disabled false
trait :with_admin_role do
after_build do |user|
admin_role = Role.find_by_name("ADMINISTRATOR") || FactoryGirl.build(:admin_role)
user.roles = [admin_role]
end
end
factory :admin, :traits => [:with_admin_role]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment