Sha256: dc626f85562b89fc651cc200bfc130fa8c69a4fd6fcbd5b11be02337a471c148
Contents?: true
Size: 1.13 KB
Versions: 13
Compression:
Stored size: 1.13 KB
Contents
module Marty; module RSpec; module Users def populate_test_users (1..2).each { |i| Rails.configuration.marty.roles.each { |role_name| username = "#{role_name}#{i}" next if Marty::User.find_by_login(username) user = Marty::User.new user.firstname = user.login = username user.lastname = username user.active = true user.save role = Marty::Role.find_by_name(role_name.to_s) rails "Oops unknown role: #{role_name}. Was db seeded?" unless role user_role = Marty::UserRole.new user_role.user = user user_role.role = role user_role.save! } } # also create an anon user user = Marty::User.new user.login = user.firstname = user.lastname = "anon" user.active = true user.save end def system_user Marty::User.find_by_login('marty') # (system_login) end def create_user(name) Marty::User.find_or_create_by!(login: name, firstname: name, lastname: 'test', active: true) end end end end
Version data entries
13 entries across 13 versions & 1 rubygems