MSFT Sync: Don't send empty string as description

Microsoft API doesn't like it

Test plan:
- pretty trivial, specs are probably enough.

Change-Id: I1720cd9f0b78b7189a63c205c21bb5299d0840e6
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/262050
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: Weston Dransfield <wdransfield@instructure.com>
Product-Review: Evan Battaglia <ebattaglia@instructure.com>
This commit is contained in:
Evan Battaglia 2021-03-31 16:51:55 -04:00
parent bb4092d8c5
commit b0655c91c9
2 changed files with 13 additions and 2 deletions

View File

@ -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,

View File

@ -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!&?' }