closes LA-791
flag = none
Test Plan:
- verify that attachments can still be created
- when adding an attachment, verify the root_account_id is set
when related to a context with a root_account_id
Change-Id: Ic294aad654deb5c154d0396bcc99565720fbd07b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/238602
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Clint Furse <cfurse@instructure.com>
This is the first part of submission drafts that only account for file
uploads. Other types (body, media comments, etc) will be coming in
future commits.
Fixes COMMS-2050
Test Plan:
- Migrate your database with this patchset checked out
`bundle exec rake db:migrate:up VERSION=20190503151652`
- Have some attachments in your database
- Have a course with a studnet in it
- Create and publish a new assignment in this course
- Open the rails console, and notice that the submission for the
student does not have any submission drafts associated with it
```
s = Submission.last
s.submission_drafts.empty? # Should be true
```
- Create a new submission draft with some attachments in the console,
and notice that you can see the draft and attachmetns from the
submission
```
draft = SubmissionDraft.new(submission_attempt: 0)
submission = Submission.last
submission.submission_drafts << draft
attachments = Attachment.limit 3
draft.attachments = attachments
submission.submission_drafts # Should show the new draft
submission.submission_drafts.first.attachments # The attachments
```
- From the web ui, submit the assignment as the student.
- Back in the rails console, and notice that the submission draft
has now been deleted
```
submission.reload
submission.submission_drafts # Should now be []
SubmissionDraft.count # Should be 0
SubmissionDraftAttachment.count # Should be 0
```
- Notice that the attachments in the rails console have not been
deleted.
```
attachments.each(&:reload)
attachments.map(&:persisted?) # Should all be true
```
- Make sure you cannot create a draft that has a higher attempt then
the root submission:
```
SubmissionDraft.create!(
submisison: submission,
submission_attempt: 0
) # Should raise a RecordInvalid error
```
- Undo the database migration until this gets merged.
`bundle exec rake db:migrate:down VERSION=20190503151652`
Change-Id: Ibedda3719e582b3aa67f049699603f3fc7cbc145
Reviewed-on: https://gerrit.instructure.com/192212
Tested-by: Jenkins
QA-Review: Matthew Lemon <mlemon@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Landon Gilbert-Bland <lbland@instructure.com>