Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ group :test do
end

gem "tailwindcss-rails", "~> 4.6"
gem "faker", "~> 3.8", group: :development
# Used for database seeding
gem "faker", "~> 3.8"
1 change: 1 addition & 0 deletions config/ci.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
step "Security: Importmap vulnerability audit", "bin/importmap audit"
step "Security: Brakeman code analysis", "bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error"
step "Tests: Rails", "bin/rails test"
step "Tests: Seeds", "env RAILS_ENV=test bin/rails db:seed:replant"

# Optional: Run system tests
# step "Tests: System", "bin/rails test:system"
Expand Down
38 changes: 22 additions & 16 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
return unless Rails.env.development?

programs = Program.create! [ { name: "Know Your Health" }, { name: "3D Wellness" } ]
def maybe(&block)
return unless Faker::Boolean.boolean

kyh, tdw = programs
ContentModule.levels.keys.each_with_index do |level, li|
[ kyh, tdw ].each do |program|
2.times do |i|
mod = program.content_modules.create!(name: "#{program.name} #{level.humanize} Module #{i + 1}", level: level, position: i + 1)
mod.links.create!(title: "Survey #{i + 1}", url: "https://example.com/survey/#{program.id}-#{level}-#{i}", link_type: "survey", position: 1)
end
end
block.call
end

programs = [
Program.find_or_create_by!(name: "Know Your Health"),
Program.find_or_create_by!(name: "3D Wellness")
]
User.find_or_create_by!(email_address: "admin@example.com") do |user|
user.name = "Admin"
user.password = "password"
end

school = School.find_or_create_by!(name: "Example School")
# Production should not have any seeded data for the content or schools
return if Rails.env.production?

def maybe(&block)
return unless Faker::Boolean.boolean

block.call
ContentModule.levels.keys.each do |level|
programs.each do |program|
2.times do |i|
mod = program.content_modules.create!(name: "#{program.name} #{level.humanize} Module #{i + 1}", level: level, position: i + 1)
# TODO: Update this when the delegated types migration is completed
link = Link.new(title: "Survey #{i + 1}", url: "https://example.com/survey/#{program.id}-#{level}-#{i}", link_type: "survey", position: 1, content_module: mod)
mod.contents.create! contentable: link
end
end
end



school = School.find_or_create_by!(name: "Example School")

teachers = 3.times.map do
school.teachers.create!(
name: Faker::Name.name,
Expand Down
Loading