diff --git a/lib/microsoft_sync/canvas_graph_service.rb b/lib/microsoft_sync/canvas_graph_service.rb index 1d8a6885260..9de3dec4f05 100644 --- a/lib/microsoft_sync/canvas_graph_service.rb +++ b/lib/microsoft_sync/canvas_graph_service.rb @@ -39,7 +39,7 @@ module MicrosoftSync # Returns the hash of the new course, including the 'id' key def create_education_class(course) graph_service.create_education_class( - description: course.public_description, + description: course.public_description.presence, displayName: course.name, externalId: course.uuid, externalName: course.name, diff --git a/spec/lib/microsoft_sync/canvas_graph_service_spec.rb b/spec/lib/microsoft_sync/canvas_graph_service_spec.rb index 9f76a974979..b7ddbf2af61 100644 --- a/spec/lib/microsoft_sync/canvas_graph_service_spec.rb +++ b/spec/lib/microsoft_sync/canvas_graph_service_spec.rb @@ -53,10 +53,21 @@ describe MicrosoftSync::CanvasGraphService do mailNickname: "Course_math_101-#{@course.uuid.first(13)}", ).and_return('foo') - expect(subject.create_education_class(@course)).to eq('foo') end + context 'when the course has a empty string for a description' do + # Microsoft API seems to have a problem with description being an empty + # string + it 'sends nil instead of the empty string' do + course_model(public_description: '', name: 'math 101') + expect(graph_service).to receive(:create_education_class).with( + hash_including(description: nil) + ).and_return('foo') + subject.create_education_class(@course) + end + end + context 'when the course code contains special characters' do let(:course_code) { '{{math🔥一241!&?' }