app/handlers/openstax/connect/dev/users_generate.rb in openstax_connect-0.0.2 vs app/handlers/openstax/connect/dev/users_generate.rb in openstax_connect-0.0.3

- old
+ new

@@ -1,8 +1,8 @@ module OpenStax::Connect::Dev class UsersGenerate - include Lev::Handler + lev_handler protected paramify :generate do attribute :count, type: Integer @@ -12,20 +12,22 @@ def authorized? !Rails.env.production? end - def exec + def handle generate_params.count.times do while !(User.where(:username => (username = SecureRandom.hex(4))).empty?) do; end u = User.create do |user| user.first_name = "Jane#{username}" user.last_name = "Doe#{username}" user.username = username user.is_administrator = false user.openstax_uid = available_openstax_uid end + + result.outputs.add(:users, u) end end def available_openstax_uid (User.order("openstax_uid DESC").first.try(:openstax_uid) || 0) + 1 \ No newline at end of file