Skip to content

Instantly share code, notes, and snippets.

@mycargus
Created March 31, 2017 15:44
Show Gist options
  • Save mycargus/8295111d07db290dcea1678b75337010 to your computer and use it in GitHub Desktop.
Save mycargus/8295111d07db290dcea1678b75337010 to your computer and use it in GitHub Desktop.
You can save this file and run it in a rails runner like so: 'bundle exec rails runner seed.rb'. Or you can simply copy/paste into a rails console.
require 'spec/factories/course_factory'
require 'spec/factories/user_factory'
include Factories
# Create, register, and enroll teacher
course_with_teacher(
active_course: 1,
active_enrollment: 1,
course_name: 'E2E Course',
name: 'Teacher 1'
)
@user.pseudonyms.create!(
unique_id: 'teacher1@example.com',
password: 'password',
password_confirmation: 'password'
)
@user.email = 'teacher1@example.com'
@user.accept_terms
@user.register!
# Create and enroll 5 students
5.times do |i|
index = i + 1
course_with_student(
active_all: 1,
course: @course,
name: "Student #{index}"
)
email = "student#{index}@example.com"
@user.pseudonyms.create!(
unique_id: email,
password: 'password',
password_confirmation: 'password'
)
@user.email = email
@user.accept_terms
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment