
* User can create programming group with other users for exercise * Submission is shared in a group * Also adjust specs
21 lines
627 B
Ruby
21 lines
627 B
Ruby
# frozen_string_literal: true
|
|
|
|
FactoryBot.define do
|
|
factory :submission do
|
|
cause { 'save' }
|
|
created_by_external_user
|
|
exercise factory: :math
|
|
|
|
after(:create) do |submission|
|
|
submission.exercise.files.editable.visible.each do |file|
|
|
submission.add_file(content: file.content, file_id: file.id)
|
|
end
|
|
|
|
# Do not change anything if a study group was provided explicitly or user has no study groups
|
|
next if submission.study_group.present? || submission.users.first.study_groups.blank?
|
|
|
|
submission.update!(study_group: submission.users.first.study_groups.first)
|
|
end
|
|
end
|
|
end
|