Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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 => '', :branch => 'master'
2. Run bundle install again
3. Append following to en.yml
(for example (in locales folder) wget -qO- | 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)
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