Prevent creation of temporary users while seeding

This commit is contained in:
Sebastian Serth
2021-07-12 20:31:24 +02:00
parent d576136846
commit bf8d8284e2
5 changed files with 34 additions and 27 deletions

View File

@@ -4,7 +4,10 @@ require 'seeds_helper'
def create_seed_file(exercise, path, file_attributes = {})
file_extension = File.extname(path)
file_type = FactoryBot.create(file_attributes[:file_type] || :"dot_#{file_extension.delete('.')}")
file_type = FactoryBot.create(
file_attributes[:file_type] || :"dot_#{file_extension.delete('.')}",
user: exercise.user
)
name = File.basename(path).gsub(file_extension, '')
file_attributes.merge!(file_type: file_type, name: name, path: path.split('/')[1..-2].join('/'), role: file_attributes[:role] || 'regular_file')
if file_type.binary?