Review points, specs
This commit is contained in:
@ -66,8 +66,12 @@ module ProformaService
|
|||||||
end
|
end
|
||||||
|
|
||||||
def file_type(extension)
|
def file_type(extension)
|
||||||
FileType.find_by(file_extension: extension) ||
|
FileType.find_or_create_by(file_extension: extension) do |file_type|
|
||||||
FileType.create(file_extension: extension, name: extension[1..-1], user: @user, indent_size: 4, editor_mode: 'ace/mode/plain_text')
|
file_type.name = extension[1..-1]
|
||||||
|
file_type.user = @user
|
||||||
|
file_type.indent_size = 4
|
||||||
|
file_type.editor_mode = 'ace/mode/plain_text'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -344,7 +344,7 @@ en:
|
|||||||
import_codeharbor:
|
import_codeharbor:
|
||||||
import_errors:
|
import_errors:
|
||||||
invalid: Invalid exercise
|
invalid: Invalid exercise
|
||||||
internal_error: An internal error occurred on Codeocean while importing the exercise.
|
internal_error: An internal error occurred on CodeOcean while importing the exercise.
|
||||||
export_codeharbor:
|
export_codeharbor:
|
||||||
label: Export to Codeharbor
|
label: Export to Codeharbor
|
||||||
dialogtitle: Export to Codeharbor
|
dialogtitle: Export to Codeharbor
|
||||||
|
@ -69,7 +69,7 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
Proforma::TaskFile.new(
|
Proforma::TaskFile.new(
|
||||||
id: 'id',
|
id: 'id',
|
||||||
content: content,
|
content: content,
|
||||||
filename: "#{path}filename.txt",
|
filename: filename,
|
||||||
used_by_grader: 'used_by_grader',
|
used_by_grader: 'used_by_grader',
|
||||||
visible: 'yes',
|
visible: 'yes',
|
||||||
usage_by_lms: usage_by_lms,
|
usage_by_lms: usage_by_lms,
|
||||||
@ -78,6 +78,7 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
mimetype: mimetype
|
mimetype: mimetype
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
let(:filename) { "#{path}filename.txt" }
|
||||||
let(:usage_by_lms) { 'display' }
|
let(:usage_by_lms) { 'display' }
|
||||||
let(:mimetype) { 'mimetype' }
|
let(:mimetype) { 'mimetype' }
|
||||||
let(:binary) { false }
|
let(:binary) { false }
|
||||||
@ -148,6 +149,18 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
expect(convert_to_exercise_service.files).to be_empty
|
expect(convert_to_exercise_service.files).to be_empty
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when file has an unkown file_type' do
|
||||||
|
let(:filename) { 'unknown_file_type.asdf' }
|
||||||
|
|
||||||
|
it 'creates a new Exercise on save' do
|
||||||
|
expect { convert_to_exercise_service.save! }.to change(Exercise, :count).by(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'creates the missing FileType on save' do
|
||||||
|
expect { convert_to_exercise_service.save! }.to change(FileType, :count).by(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when task has a model-solution' do
|
context 'when task has a model-solution' do
|
||||||
|
Reference in New Issue
Block a user