Files
akkounts/db/seeds.rb
raucao 911d2a5855
CI / Test (pull_request) Successful in 45s
Release Drafter / Update release notes draft (pull_request) Successful in 3s
Fix db seeds for Solid Queue
db/seeds.rb still required "sidekiq/testing" and wrapped seeding in
Sidekiq::Testing.inline!, but Sidekiq is no longer in the bundle after
the Solid Queue migration, so `rails db:setup` failed with a LoadError.

Run the jobs triggered while seeding inline via Active Job instead,
restoring the previous behavior with the adapter the app actually uses.
2026-10-06 13:36:33 +00:00

32 lines
858 B
Ruby

ldap = LdapService.new
original_queue_adapter = ActiveJob::Base.queue_adapter
ActiveJob::Base.queue_adapter = :inline
begin
ldap.delete_all_users!
puts "Create user: admin"
UserManager::CreateAccount.call(account: {
username: "admin", domain: "kosmos.org", email: "admin@example.com",
password: "admin is admin", confirmed: true
})
ldap.add_attribute "cn=admin,ou=kosmos.org,cn=users,dc=kosmos,dc=org", :admin, "true"
puts "Create 35 random users"
35.times do |n|
username = Faker::Name.unique.first_name.downcase
email = Faker::Internet.unique.email
next if username.length < 3
UserManager::CreateAccount.call(account: {
username: username, domain: "kosmos.org", email: email,
password: "user is user", confirmed: true
})
end
ensure
ActiveJob::Base.queue_adapter = original_queue_adapter
end