fix `undefined method `pronouns' for nil:NilClass` bug
Closes: WOKE-93 Test plan: * go to a public course as a non logged in user * make sure the Course has a discussion topic * load the assignment index page * it should not have a 500 error for the XHR request Change-Id: I45148dca86e41d3bee68b211c58a13e8aaf21b49 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/216074 Reviewed-by: Landon Gilbert-Bland <lbland@instructure.com> Tested-by: Ryan Shaw <ryan@instructure.com> QA-Review: Ryan Shaw <ryan@instructure.com> Product-Review: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
parent
e30dc49859
commit
ea8157447e
|
@ -145,7 +145,7 @@ module Api::V1::DiscussionTopics
|
|||
end
|
||||
end
|
||||
|
||||
if user.pronouns
|
||||
if user&.pronouns
|
||||
json[:user_pronouns] = user.pronouns
|
||||
end
|
||||
|
||||
|
|
|
@ -144,6 +144,11 @@ describe Api::V1::DiscussionTopics do
|
|||
expect(data[:assignment]).to be_nil
|
||||
end
|
||||
|
||||
it "should not die if user is nil (like when a non-logged-in user visits a public course)" do
|
||||
data = @test_api.discussion_topic_api_json(@topic, @topic.context, nil, nil)
|
||||
expect(data).to be_present
|
||||
end
|
||||
|
||||
context "with assignment" do
|
||||
before :once do
|
||||
@topic.assignment = assignment_model(:course => @course)
|
||||
|
|
Loading…
Reference in New Issue