Fix seeds for execution environment import and study group membership
This commit is contained in:

committed by
Sebastian Serth

parent
5e90a93f9d
commit
6ad5274e67
@ -1,5 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'highline/import'
|
||||||
|
|
||||||
# consumers
|
# consumers
|
||||||
FactoryBot.create(:consumer)
|
FactoryBot.create(:consumer)
|
||||||
FactoryBot.create(:consumer, name: 'openSAP')
|
FactoryBot.create(:consumer, name: 'openSAP')
|
||||||
@ -9,15 +11,17 @@ FactoryBot.create(:consumer, name: 'Xikolo Development', oauth_key: 'consumer',
|
|||||||
# users
|
# users
|
||||||
# Set default_url_options explicitly, required for rake task
|
# Set default_url_options explicitly, required for rake task
|
||||||
Rails.application.routes.default_url_options = Rails.application.config.action_mailer.default_url_options
|
Rails.application.routes.default_url_options = Rails.application.config.action_mailer.default_url_options
|
||||||
admin = FactoryBot.create(:admin)
|
UserMailer.delivery_method = :test
|
||||||
teacher = FactoryBot.create(:teacher, email: 'teacher@example.org')
|
admin = FactoryBot.create(:admin, study_groups: StudyGroup.all)
|
||||||
FactoryBot.create(:learner, email: 'learner@example.org')
|
teacher = FactoryBot.create(:teacher, email: 'teacher@example.org', study_groups: StudyGroup.all)
|
||||||
external_user = FactoryBot.create(:external_user)
|
FactoryBot.create(:learner, email: 'learner@example.org', study_groups: StudyGroup.all)
|
||||||
|
external_user = FactoryBot.create(:external_user, study_groups: StudyGroup.all)
|
||||||
|
|
||||||
# file types
|
# file types
|
||||||
FileType.create_factories user: admin
|
FileType.create_factories user: admin
|
||||||
|
|
||||||
# execution environments
|
# execution environments
|
||||||
|
ExecutionEnvironment.skip_callback(:commit, :after, :sync_runner_environment)
|
||||||
ExecutionEnvironment.create_factories user: admin
|
ExecutionEnvironment.create_factories user: admin
|
||||||
|
|
||||||
# exercises
|
# exercises
|
||||||
@ -25,3 +29,15 @@ ExecutionEnvironment.create_factories user: admin
|
|||||||
|
|
||||||
# submissions
|
# submissions
|
||||||
FactoryBot.create(:submission, exercise: @exercises[:fibonacci], user: external_user)
|
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
|
||||||
|
@ -13,7 +13,7 @@ passwords = ['password', 'password confirmation'].map do |attribute|
|
|||||||
end
|
end
|
||||||
|
|
||||||
if passwords.uniq.length == 1
|
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
|
else
|
||||||
abort('Passwords do not match!')
|
abort('Passwords do not match!')
|
||||||
end
|
end
|
||||||
@ -22,15 +22,26 @@ end
|
|||||||
FileType.create_factories user: admin
|
FileType.create_factories user: admin
|
||||||
|
|
||||||
# execution environments
|
# execution environments
|
||||||
|
ExecutionEnvironment.skip_callback(:commit, :after, :sync_runner_environment)
|
||||||
ExecutionEnvironment.create_factories user: admin
|
ExecutionEnvironment.create_factories user: admin
|
||||||
|
|
||||||
# exercises
|
# exercises
|
||||||
Exercise.create_factories user: admin
|
Exercise.create_factories user: admin
|
||||||
|
|
||||||
say(<<~CONFIRMATION_MESSAGE)
|
say(<<~CONFIRMATION_MESSAGE)
|
||||||
Production data has been seeded successfully. As part \
|
Production data has been seeded successfully.
|
||||||
of this setup, a test email was sent to '#{email}'. You \
|
|
||||||
can safely ignore this mail as your account is already \
|
As part of this setup, a test email was sent to \
|
||||||
confirmed. However, if you haven't received any email, \
|
'#{email}'. You can safely ignore this mail as your \
|
||||||
you should check the server's mail settings.
|
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
|
CONFIRMATION_MESSAGE
|
||||||
|
Reference in New Issue
Block a user