Skip to content

Instantly share code, notes, and snippets.

@mycargus
Created September 26, 2016 18:57
Show Gist options
  • Save mycargus/45d9d8440a10a90033cd84f9b36d1658 to your computer and use it in GitHub Desktop.
Save mycargus/45d9d8440a10a90033cd84f9b36d1658 to your computer and use it in GitHub Desktop.
A ruby script that creates a course and 6 users, enrolls one user as a teacher in the course, and enrolls the remaining 5 users as students in the course
require 'spec/factories/course_factory'
require 'spec/factories/user_factory'
# 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