Change to user unfiled folder for attachments

This matches the legacy behavior, students
where getting a 403 because they can't add to
the course folder.

closes VICE-3270
flag=react_discussions_post

test plan:
  - Visit a discussion as a student.
  - Create a reply and add an attachment.
  - Submit.
  - Should add and show without issue.

qa risk: low

Change-Id: I93a9674eea9f8898124563a601ef69aecc1307ae
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/307886
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Chawn Neal <chawn.neal@instructure.com>
Product-Review: Chawn Neal <chawn.neal@instructure.com>
QA-Review: Drake Harper <drake.harper@instructure.com>
This commit is contained in:
Omar Gerardo Soto-Fortuño 2022-12-22 09:53:20 -05:00 committed by Omar Soto-Fortuño
parent 1bebaaaece
commit 38f24461ab
2 changed files with 3 additions and 3 deletions

View File

@ -794,7 +794,7 @@ class DiscussionTopicsController < ApplicationController
DISCUSSION: {
GRADED_RUBRICS_URL: (@topic.assignment ? context_url(@topic.assignment.context, :context_assignment_rubric_url, @topic.assignment.id) : nil),
CONTEXT_RUBRICS_URL: can_do(@topic.assignment, @current_user, :update) ? context_url(@topic.assignment.context, :context_rubrics_url) : "",
ATTACHMENTS_FOLDER_ID: (@topic.for_assignment? && !@current_user.nil?) ? @current_user.submissions_folder(@context).id : Folder.unfiled_folder(@context).id,
ATTACHMENTS_FOLDER_ID: @current_user.nil? ? Folder.unfiled_folder(@context).id : Folder.unfiled_folder(@current_user).id,
preferences: {
discussions_splitscreen_view: @current_user&.discussions_splitscreen_view? || false
}

View File

@ -561,7 +561,7 @@ describe DiscussionTopicsController do
subject
expect(discussion).not_to be_for_assignment
expect(assigns[:js_env][:DISCUSSION][:ATTACHMENTS_FOLDER_ID]).to eq Folder.unfiled_folder(discussion.course).id.to_s
expect(assigns[:js_env][:DISCUSSION][:ATTACHMENTS_FOLDER_ID]).to eq Folder.unfiled_folder(user).id.to_s
end
context "no current user" do
@ -593,7 +593,7 @@ describe DiscussionTopicsController do
subject
expect(discussion).to be_for_assignment
expect(assigns[:js_env][:DISCUSSION][:ATTACHMENTS_FOLDER_ID]).to eq user.submissions_folder(discussion.course).id.to_s
expect(assigns[:js_env][:DISCUSSION][:ATTACHMENTS_FOLDER_ID]).to eq Folder.unfiled_folder(user).id.to_s
end
end