Fix seeds for execution environment import and study group membership

This commit is contained in:
Sebastian Serth
2022-09-22 13:33:45 +02:00
committed by Sebastian Serth
parent 5e90a93f9d
commit 6ad5274e67
2 changed files with 37 additions and 10 deletions

View File

@ -1,5 +1,7 @@
# frozen_string_literal: true
require 'highline/import'
# consumers
FactoryBot.create(:consumer)
FactoryBot.create(:consumer, name: 'openSAP')
@ -9,15 +11,17 @@ FactoryBot.create(:consumer, name: 'Xikolo Development', oauth_key: 'consumer',
# users
# Set default_url_options explicitly, required for rake task
Rails.application.routes.default_url_options = Rails.application.config.action_mailer.default_url_options
admin = FactoryBot.create(:admin)
teacher = FactoryBot.create(:teacher, email: 'teacher@example.org')
FactoryBot.create(:learner, email: 'learner@example.org')
external_user = FactoryBot.create(:external_user)
UserMailer.delivery_method = :test
admin = FactoryBot.create(:admin, study_groups: StudyGroup.all)
teacher = FactoryBot.create(:teacher, email: 'teacher@example.org', study_groups: StudyGroup.all)
FactoryBot.create(:learner, email: 'learner@example.org', study_groups: StudyGroup.all)
external_user = FactoryBot.create(:external_user, study_groups: StudyGroup.all)
# file types
FileType.create_factories user: admin
# execution environments
ExecutionEnvironment.skip_callback(:commit, :after, :sync_runner_environment)
ExecutionEnvironment.create_factories user: admin
# exercises
@ -25,3 +29,15 @@ ExecutionEnvironment.create_factories user: admin
# submissions
FactoryBot.create(:submission, exercise: @exercises[:fibonacci], user: external_user)
say(<<~CONFIRMATION_MESSAGE)
Development data has been seeded successfully.
As part of this setup, some execution environments have been \
stored in the database. However, these haven't been yet \
synchronized with a runner management. Please take care \
to configure a runner management according to the \
documentation and synchronize environments thorugh the \
user interface. To do so, open `/execution_environments` \
and click on the "Synchronize all" button.
CONFIRMATION_MESSAGE

View File

@ -13,7 +13,7 @@ passwords = ['password', 'password confirmation'].map do |attribute|
end
if passwords.uniq.length == 1
admin = FactoryBot.create(:admin, email: email, name: 'Administrator', password: passwords.first)
admin = FactoryBot.create(:admin, email: email, name: 'Administrator', password: passwords.first, study_groups: StudyGroup.all)
else
abort('Passwords do not match!')
end
@ -22,15 +22,26 @@ end
FileType.create_factories user: admin
# execution environments
ExecutionEnvironment.skip_callback(:commit, :after, :sync_runner_environment)
ExecutionEnvironment.create_factories user: admin
# exercises
Exercise.create_factories user: admin
say(<<~CONFIRMATION_MESSAGE)
Production data has been seeded successfully. As part \
of this setup, a test email was sent to '#{email}'. You \
can safely ignore this mail as your account is already \
confirmed. However, if you haven't received any email, \
you should check the server's mail settings.
Production data has been seeded successfully.
As part of this setup, a test email was sent to \
'#{email}'. You can safely ignore this mail as your \
account is already confirmed. However, if you \
haven't received any email, you should check the \
server's mail settings.
Additionally, some execution environments have been \
stored in the database. However, these haven't been yet \
synchronized with a runner management. Please take care \
to configure a runner management according to the \
documentation and synchronize environments thorugh the \
user interface. To do so, open `/execution_environments` \
and click on the "Synchronize all" button.
CONFIRMATION_MESSAGE