fix file_type selection for Makefile
This commit is contained in:
@ -101,7 +101,7 @@ module ProformaService
|
||||
end
|
||||
|
||||
def file_type(extension)
|
||||
FileType.find_or_create_by(file_extension: extension) do |file_type|
|
||||
FileType.find_or_create_by(file_extension: extension.presence) do |file_type|
|
||||
file_type.name = extension[1..]
|
||||
file_type.user = @user
|
||||
file_type.indent_size = 4
|
||||
|
@ -232,6 +232,20 @@ describe ProformaService::ConvertTaskToExercise do
|
||||
expect { convert_to_exercise_service.save! }.to change(FileType, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when file has a Makefile' do
|
||||
let!(:file_type) { create(:makefile) }
|
||||
|
||||
let(:filename) { 'Makefile' }
|
||||
|
||||
it 'creates a new Exercise on save' do
|
||||
expect { convert_to_exercise_service.save! }.to change(Exercise, :count).by(1)
|
||||
end
|
||||
|
||||
it 'creates an exercise with a file with correct attributes' do
|
||||
expect(convert_to_exercise_service.files.first.file_type).to eql file_type
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when task has a model-solution' do
|
||||
|
Reference in New Issue
Block a user