Skip to content

Instantly share code, notes, and snippets.

@acosonic
Last active August 21, 2019 07:59
Show Gist options
  • Save acosonic/136ba9a9976130e8da40abc0e1c3fde1 to your computer and use it in GitHub Desktop.
Save acosonic/136ba9a9976130e8da40abc0e1c3fde1 to your computer and use it in GitHub Desktop.
Using Faker gem, to create 99 test users in Redmine using rails console
This code will produce users with first/last names and emails for English language and assumes that English is default
for your Redmine installation
1. Add faker gem to Redmine's Gemfile
gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'master'
2. Run bundle install again
3. Append following to en.yml
https://gist.github.com/acosonic/4569608db998c80fee6a37c104fc352b
(for example (in locales folder) wget -qO- https://gist.githubusercontent.com/acosonic/4569608db998c80fee6a37c104fc352b/raw/3d572a5a958ca3bba732a034800d2c3a6dce678a/faker.yml | tee -a en.yml)
4. Run rails console
5. Use the following code:
99.times do |n|
login = Faker::Internet.unique.username
hashed_password = "dcd3ba2c1c58b25ae87a591140ae4a0e8fd5d704"
firstname = Faker::Name.unique.first_name
lastname = Faker::Name.unique.last_name
status = 1
mail = Faker::Internet.unique.safe_email
User.create!(login: login, hashed_password: hashed_password, firstname: firstname, lastname: lastname, status: status, mail: mail)
end
Later to test your users, you can use some of plugins like:
spectator plugin or some other plugin allowing admin to act as different user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment